<!DOCTYPE html>

































































<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" type="image/x-icon" href="../../../favicon.ico" />
<title>Drawable Resources | Android Developers</title>
<link href="../../../assets/android-developer-docs-devguide.css" rel="stylesheet" type="text/css" />
<script src="../../../assets/search_autocomplete.js" type="text/javascript"></script>
<script src="../../../assets/jquery-resizable.min.js" type="text/javascript"></script>
<script src="../../../assets/android-developer-docs.js" type="text/javascript"></script>
<script src="../../../assets/prettify.js" type="text/javascript"></script>
<script type="text/javascript">
  setToRoot("../../../");
</script>
<noscript>
  <style type="text/css">
    html,body{overflow:auto;}
    #body-content{position:relative; top:0;}
    #doc-content{overflow:visible;border-left:3px solid #666;}
    #side-nav{padding:0;}
    #side-nav .toggle-list ul {display:block;}
    #resize-packages-nav{border-bottom:3px solid #666;}
  </style>
</noscript>
</head>
<body class="gc-documentation">

  <div id="header">
      <div id="headerLeft">
          <a href="../../../index.html" tabindex="-1"><img
              src="../../../assets/images/bg_logo.png" alt="Android Developers" /></a>
          <ul id="header-tabs" class="guide">
    
	<li id="home-link"><a href="../../../offline.html">
	
		<span class="en">Home</span>
		<span style="display:none" class="de">Startseite</span>
		<span style="display:none" class="es"></span>
		<span style="display:none" class="fr"></span>
		<span style="display:none" class="it"></span>
		<span style="display:none" class="ja">ホーム</span>
		<span style="display:none" class="zh-CN">主页</span>
		<span style="display:none" class="zh-TW">首頁</span>
	
	</a></li>
	<li id="sdk-link"><a href="../../../sdk/index.html">
		<span class="en">SDK</span>
	</a></li>
	<li id="guide-link"><a href="../../../guide/index.html" onClick="return loadLast('guide')">
	
		<span class="en">Dev Guide</span>
		<span style="display:none" class="de">Handbuch</span>
		<span style="display:none" class="es">Guía</span>
		<span style="display:none" class="fr">Guide</span>
		<span style="display:none" class="it">Guida</span>
		<span style="display:none" class="ja">開発ガイド</span>
		<span style="display:none" class="zh-CN">开发人员指南</span>
		<span style="display:none" class="zh-TW">開發指南</span>
	
	</a></li>
	<li id="reference-link"><a href="../../../reference/packages.html" onClick="return loadLast('reference')">
	
		<span class="en">Reference</span>
		<span style="display:none" class="de">Referenz</span>
		<span style="display:none" class="es">Referencia</span>
		<span style="display:none" class="fr">Référence</span>
		<span style="display:none" class="it">Riferimento</span>
		<span style="display:none" class="ja">リファレンス</span>
		<span style="display:none" class="zh-CN">参考</span>
		<span style="display:none" class="zh-TW">參考資料</span>
	
	</a></li>
	<li id="resources-link"><a href="../../../resources/index.html" onClick="return loadLast('resources')">
	
		<span class="en">Resources</span>
		<span style="display:none" class="de"></span>
		<span style="display:none" class="es"></span>
		<span style="display:none" class="fr"></span>
		<span style="display:none" class="it"></span>
    		<span style="display:none" class="ja"></span>
		<span style="display:none" class="zh-CN"></span>
		<span style="display:none" class="zh-TW"></span>
	
	</a></li>
	<li id="videos-link"><a href="../../../videos/index.html" onClick="return loadLast('videos')">
	
		<span class="en">Videos</span>
		<span style="display:none" class="de"></span>
		<span style="display:none" class="es"></span>
		<span style="display:none" class="fr"></span>
		<span style="display:none" class="it"></span>
		<span style="display:none" class="ja">ビデオ</span>
		<span style="display:none" class="zh-CN"></span>
		<span style="display:none" class="zh-TW"></span>
	
	</a></li>
	<li><a href="http://android-developers.blogspot.com" onClick="return requestAppendHL(this.href)">
	
		<span class="en">Blog</span>
		<span style="display:none" class="de"></span>
		<span style="display:none" class="es"></span>
		<span style="display:none" class="fr"></span>
		<span style="display:none" class="it"></span>
		<span style="display:none" class="ja">ブログ</span>
		<span style="display:none" class="zh-CN">博客</span>
		<span style="display:none" class="zh-TW">網誌</span>
	
	</a></li>


     
</ul>
     
      </div>
      <div id="headerRight">
          <div id="headerLinks">
          
          <a href="http://www.android.com">Android.com</a>
          </div>
  <div id="search" >
      <div id="searchForm">
          <form accept-charset="utf-8" class="gsc-search-box" 
                onsubmit="return submit_search()">
            <table class="gsc-search-box" cellpadding="0" cellspacing="0"><tbody>
                <tr>
                  <td class="gsc-input">
                    <input id="search_autocomplete" class="gsc-input" type="text" size="33" autocomplete="off"
                      title="search developer docs" name="q"
                      value="search developer docs"
                      onFocus="search_focus_changed(this, true)"
                      onBlur="search_focus_changed(this, false)"
                      onkeydown="return search_changed(event, true, '../../../')"
                      onkeyup="return search_changed(event, false, '../../../')" />
                  <div id="search_filtered_div" class="no-display">
                      <table id="search_filtered" cellspacing=0>
                      </table>
                  </div>
                  </td>
                  <td class="gsc-search-button">
                    <input type="submit" value="Search" title="search" id="search-button" class="gsc-search-button" />
                  </td>
                  <td class="gsc-clear-button">
                    <div title="clear results" class="gsc-clear-button">&nbsp;</div>
                  </td>
                </tr></tbody>
              </table>
          </form>
      </div><!-- searchForm -->
  </div><!-- search -->
      </div><!-- headerRight -->
      <script type="text/javascript">
        <!--  
        changeTabLang(getLangPref());
        //-->
      </script>
  </div><!-- header -->

  <div class="g-section g-tpl-240" id="body-content">
    <div class="g-unit g-first" id="side-nav">
      <div id="devdoc-nav">
<ul>

  <li>
    <h2><span class="en">Android Basics</span>
        <span class="de" style="display:none">Einführung in Android</span>
        <span class="es" style="display:none">Información básica sobre Android</span>
        <span class="fr" style="display:none">Présentation d'Android</span>
        <span class="it" style="display:none">Nozioni di base su Android</span>
        <span class="ja" style="display:none">Android の基本</span>
        <span class="zh-CN" style="display:none">Android 基础知识</span>
        <span class="zh-TW" style="display:none">Android 簡介</span>
    </h2>
    <ul>
      <li><a href="../../../guide/basics/what-is-android.html">
        <span class="en">What Is Android?</span>
        <span class="de" style="display:none">Was ist Android?</span>
        <span class="es" style="display:none">¿Qué es Android?</span>
        <span class="fr" style="display:none">Qu'est-ce qu'Android&nbsp;?</span>
        <span class="it" style="display:none">Che cos'è Android?</span>
        <span class="ja" style="display:none">Android とは</span>
        <span class="zh-CN" style="display:none">Android 是什么？</span>
        <span class="zh-TW" style="display:none">什麼是 Android？</span>
          </a></li>
      <li><a href="../../../guide/topics/fundamentals.html">
        <span class="en">Application Fundamentals</span>
        <span class="de" style="display:none">Anwendungsgrundlagen</span>
        <span class="es" style="display:none">Fundamentos de las aplicaciones</span>
        <span class="fr" style="display:none">Principes de base des applications</span>
        <span class="it" style="display:none">Concetti fondamentali sulle applicazioni</span>
        <span class="ja" style="display:none">開発の基礎</span>
        <span class="zh-CN" style="display:none">应用程序基础</span>
        <span class="zh-TW" style="display:none">應用程式基本原理</span>
      </a></li>

  <!--  <li><a style="color:gray;">The Android SDK</a></li> -->
  <!--  <li><a style="color:gray;">Walkthrough for Developers</a></li> -->
      <!-- quick overview of what it's like to develop on Android -->
    </ul>
  </li>

  <li>
    <h2>
      <span class="en">Framework Topics</span>
      <span class="de" style="display:none">Framework-Themen</span>
      <span class="es" style="display:none">Temas sobre el framework</span>
      <span class="fr" style="display:none">Thèmes relatifs au framework</span>
      <span class="it" style="display:none">Argomenti relativi al framework</span>
      <span class="ja" style="display:none">フレームワーク トピック</span>
      <span class="zh-CN" style="display:none">框架主题</span>
      <span class="zh-TW" style="display:none">架構主題</span>
    </h2>
    <ul>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/fundamentals/activities.html">
          <span class="en">Activities</span>
        </a></div>
        <ul>
          <li><a href="../../../guide/topics/fundamentals/fragments.html">
            <span class="en">Fragments</span>
          </a></li>
          <li><a href="../../../guide/topics/fundamentals/loaders.html">
            <span class="en">Loaders</span>
          </a></li>
          <li><a href="../../../guide/topics/fundamentals/tasks-and-back-stack.html">
            <span class="en">Tasks and Back Stack</span></a></li>
        </ul>
      </li>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/fundamentals/services.html">
          <span class="en">Services</span>
        </a></div>
        <ul>
          <li><a href="../../../guide/topics/fundamentals/bound-services.html">
            <span class="en">Bound Services</span>
          </a></li>
        </ul>
      </li>
      <li><a href="../../../guide/topics/providers/content-providers.html">
            <span class="en">Content Providers</span>
          </a></li>
      <li><a href="../../../guide/topics/intents/intents-filters.html">
            <span class="en">Intents and Intent Filters</span>
          </a></li>
      <li><a href="../../../guide/topics/fundamentals/processes-and-threads.html">
            <span class="en">Processes and Threads</span>
          </a></li>
    </ul>


    <ul>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/ui/index.html">
            <span class="en">User Interface</span>
          </a></div>
        <ul>
          <li><a href="../../../guide/topics/ui/declaring-layout.html">
               <span class="en">XML Layouts</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/ui-events.html">
                <span class="en">Input Events</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/menus.html">
               <span class="en">Menus</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/actionbar.html">
               <span class="en">Action Bar</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/dialogs.html">
                <span class="en">Dialogs</span>
              </a></li>
          <li class="toggle-list">
            <div><a href="../../../guide/topics/ui/notifiers/index.html">
                <span class="en">Notifications</span>
            </a></div>
            <ul>
              <li><a href="../../../guide/topics/ui/notifiers/toasts.html">
                <span class="en">Toast Notifications</span>
              </a></li>
              <li><a href="../../../guide/topics/ui/notifiers/notifications.html">
                <span class="en">Status Bar Notifications</span>
              </a></li>
            </ul>
          </li>
          <li><a href="../../../guide/topics/ui/drag-drop.html">
                <span class="en">Drag and Drop</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/themes.html">
                <span class="en">Styles and Themes</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/custom-components.html">
                <span class="en">Custom Components</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/binding.html">
                <span class="en">Binding to Data with AdapterView</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/layout-objects.html">
                <span class="en">Common Layout Objects</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/how-android-draws.html">
                <span class="en">How Android Draws Views</span>
              </a></li>
        </ul>
      </li><!-- end of User Interface -->

      <li class="toggle-list">
        <div><a href="../../../guide/topics/resources/index.html">
               <span class="en">Application Resources</span>
             </a></div>
        <ul>
          <li><a href="../../../guide/topics/resources/providing-resources.html">
                <span class="en">Providing Resources</span>
              </a></li>
          <li><a href="../../../guide/topics/resources/accessing-resources.html">
                <span class="en">Accessing Resources</span>
              </a></li>
          <li><a href="../../../guide/topics/resources/runtime-changes.html">
                <span class="en">Handling Runtime Changes</span>
              </a></li>
          <li><a href="../../../guide/topics/resources/localization.html">
                <span class="en">Localization</span>
              </a></li>
          <li class="toggle-list">
            <div><a href="../../../guide/topics/resources/available-resources.html">
              <span class="en">Resource Types</span>
            </a></div>
            <ul>
              <li><a href="../../../guide/topics/resources/animation-resource.html">Animation</a></li>
              <li><a href="../../../guide/topics/resources/color-list-resource.html">Color State List</a></li>
              <li><a href="../../../guide/topics/resources/drawable-resource.html">Drawable</a></li>
              <li><a href="../../../guide/topics/resources/layout-resource.html">Layout</a></li>
              <li><a href="../../../guide/topics/resources/menu-resource.html">Menu</a></li>
              <li><a href="../../../guide/topics/resources/string-resource.html">String</a></li>
              <li><a href="../../../guide/topics/resources/style-resource.html">Style</a></li>
              <li><a href="../../../guide/topics/resources/more-resources.html">More Types</a></li>
            </ul>
          </li><!-- end of resource types -->
        </ul>
      </li><!-- end of app resources -->
      <li class="toggle-list">
        <div><a href="../../../guide/topics/data/data-storage.html">
            <span class="en">Data Storage</span>
          </a></div>
          <ul>
            <li><a href="../../../guide/topics/data/backup.html">
                <span class="en">Data Backup</span>
              </a>
            </li>
          </ul>
      </li>
      <li><a href="../../../guide/topics/security/security.html">
            <span class="en">Security and Permissions</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/manifest/manifest-intro.html">
          <span class="en">The AndroidManifest.xml File</span>
        </a></div>
        <ul>
          <li><a href="../../../guide/topics/manifest/action-element.html">&lt;action&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/activity-element.html">&lt;activity&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/activity-alias-element.html">&lt;activity-alias&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/application-element.html">&lt;application&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/category-element.html">&lt;category&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/compatible-screens-element.html">&lt;compatible-screens&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/data-element.html">&lt;data&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/grant-uri-permission-element.html">&lt;grant-uri-permission&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/instrumentation-element.html">&lt;instrumentation&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/meta-data-element.html">&lt;meta-data&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/path-permission-element.html">&lt;path-permission&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/permission-element.html">&lt;permission&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/permission-group-element.html">&lt;permission-group&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/permission-tree-element.html">&lt;permission-tree&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/provider-element.html">&lt;provider&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/receiver-element.html">&lt;receiver&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/service-element.html">&lt;service&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/supports-gl-texture-element.html">&lt;supports-gl-texture&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/supports-screens-element.html">&lt;supports-screens&gt;</a></li><!-- ##api level 4## -->
          <li><a href="../../../guide/topics/manifest/uses-configuration-element.html">&lt;uses-configuration&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/uses-feature-element.html">&lt;uses-feature&gt;</a></li> <!-- ##api level 4## -->
          <li><a href="../../../guide/topics/manifest/uses-library-element.html">&lt;uses-library&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/uses-permission-element.html">&lt;uses-permission&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/uses-sdk-element.html">&lt;uses-sdk&gt;</a></li>
        </ul>
      </li><!-- end of the manifest file -->
    </ul>

    <ul>
    <li class="toggle-list">
        <div><a href="../../../guide/topics/graphics/index.html">
            <span class="en">Graphics</span>
          </a><span class="new-child">new!</span></div>
        <ul>
          <li><a href="../../../guide/topics/graphics/2d-graphics.html">
              <span class="en">Canvas and Drawables</span></a></li>
          <li><a href="../../../guide/topics/graphics/hardware-accel.html">
              <span class="en">Hardware Acceleration</span></a>
            <span class="new">new!</span></li>
          <li><a href="../../../guide/topics/graphics/opengl.html">
              <span class="en">OpenGL</span>
            </a><span class="new">updated</span></li>
        </ul>
      </li>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/graphics/animation.html">
            <span class="en">Animation</span>
          </a></div>
        <ul>
          <li><a href="../../../guide/topics/graphics/prop-animation.html">
              <span class="en">Property Animation</span></a></li>
          <li><a href="../../../guide/topics/graphics/view-animation.html">
              <span class="en">View Animation</span></a></li>
          <li><a href="../../../guide/topics/graphics/drawable-animation.html">
              <span class="en">Drawable Animation</span></a></li>
        </ul>
      </li>
      <li class="toggle-list">
	        <div><a href="../../../guide/topics/renderscript/index.html">
	            <span class="en">RenderScript</span>
	          </a></div>
	        <ul>
	          <li><a href="../../../guide/topics/renderscript/graphics.html">
	                <span class="en">Graphics</span>
	              </a>
	          </li>
	          <li><a href="../../../guide/topics/renderscript/compute.html">
	                <span class="en">Compute</span>
	              </a>
	          </li>
	        </ul>
  	  </li>

      <li class="toggle-list">
          <div><a href="../../../guide/topics/media/index.html">
            <span class="en">Multimedia and Camera</span>
          </a><span class="new">updated</span></div>
          <ul>
            <li><a href="../../../guide/topics/media/mediaplayer.html">
                  <span class="en">Media Playback</span></a>
                </li>
            <li><a href="../../../guide/topics/media/jetplayer.html">
                  <span class="en">JetPlayer</span></a>
                </li>
            <li><a href="../../../guide/topics/media/camera.html">
                  <span class="en">Camera</span></a>
                  <span class="new">new!</span>
                </li>
            <li><a href="../../../guide/topics/media/audio-capture.html">
                  <span class="en">Audio Capture</span></a>
                </li>
          </ul>
      </li>
      <li>
        <a href="../../../guide/topics/clipboard/copy-paste.html">
            <span class="en">Copy and Paste</span>
        </a></li>
  <!--<li class="toggle-list">
        <div><a style="color:gray;">Sensors</a></div>
          <ul>
            <li><a style="color:gray;">Camera</a></li>
            <li><a style="color:gray;">Compass</a></li>
            <li><a style="color:gray;">Accelerometer</a></li>
          </ul>
      </li> -->
      <li class="toggle-list">
        <div><a href="../../../guide/topics/location/index.html">
               <span class="en">Location and Maps</span>
             </a></div>
        <ul>
          <li><a href="../../../guide/topics/location/obtaining-user-location.html">
                <span class="en">Obtaining User Location</span>
              </a></li>
        </ul>
      </li>
  <!--<li class="toggle-list">
        <div><a style="color:gray;">Wireless Controls</a></div>
          <ul>
            <li><a style="color:gray;">Wi-Fi</a></li>
          </ul>
      </li> -->
  <!--<li><a style="color:gray;">Localization</a></li>  -->
      <li><a href="../../../guide/topics/appwidgets/index.html">
            <span class="en">App Widgets</span></a>
          </li>
      <li><a href="../../../guide/topics/wireless/bluetooth.html">
            <span class="en">Bluetooth</span></a>
          </li>
      <li><a href="../../../guide/topics/nfc/index.html">
            <span class="en">Near Field Communication</span>
          </a></li>
      <li class="toggle-list">
          <div><a href="../../../guide/topics/usb/index.html">
            <span class="en">USB</span></a>
          </div>
            <ul>
              <li><a href="../../../guide/topics/usb/accessory.html">Accessory</a></li>
              <li><a href="../../../guide/topics/usb/host.html">Host</a></li>
              <li><a href="../../../guide/topics/usb/adk.html">Open Accessory Dev Kit</a></li>
            </ul>
          </li>

       <li><a href="../../../guide/topics/network/sip.html">
            <span class="en">Session Initiation Protocol</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/search/index.html">
            <span class="en">Search</span>
          </a></div>
          <ul>
            <li><a href="../../../guide/topics/search/search-dialog.html">Creating a Search Interface</a></li>
            <li><a href="../../../guide/topics/search/adding-recent-query-suggestions.html">Adding Recent Query Suggestions</a></li>
            <li><a href="../../../guide/topics/search/adding-custom-suggestions.html">Adding Custom Suggestions</a></li>
            <li><a href="../../../guide/topics/search/searchable-config.html">Searchable Configuration</a></li>
          </ul>
      </li>
      <li><a href="../../../guide/topics/admin/device-admin.html">
            <span class="en">Device Administration</span></a>
      </li>
      <li class="toggle-list">
           <div>
                <a href="../../../guide/topics/testing/index.html">
                   <span class="en">Testing</span>
               </a>
           </div>
           <ul>
              <li>
                <a href="../../../guide/topics/testing/testing_android.html">
                <span class="en">Testing Fundamentals</span></a>
              </li>
              <li>
                <a href="../../../guide/topics/testing/activity_testing.html">
                <span class="en">Activity Testing</span></a>
              </li>
              <li>
                <a href="../../../guide/topics/testing/contentprovider_testing.html">
                <span class="en">Content Provider Testing</span></a>
              </li>
              <li>
                <a href="../../../guide/topics/testing/service_testing.html">
                <span class="en">Service Testing</span></a>
              </li>
              <li>
                <a href="../../../guide/topics/testing/what_to_test.html">
                <span class="en">What To Test</span></a>
              </li>
           </ul>
      </li>
    </ul>
  </li>

  <li>
    <h2>
      <span class="en">Android Market Topics</span>
    </h2>
    <ul>
      <li><a href="../../../guide/publishing/licensing.html">
          <span class="en">Application Licensing</span></a>
      </li>
      <li class="toggle-list">
        <div><a href="../../../guide/market/billing/index.html">
            <span class="en">In-app Billing</span></a>
        </div>
        <ul>
          <li><a href="../../../guide/market/billing/billing_overview.html">
              <span class="en">In-app Billing Overview</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_integrate.html">
              <span class="en">Implementing In-app Billing</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_best_practices.html">
              <span class="en">Security and Design</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_testing.html">
              <span class="en">Testing In-app Billing</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_admin.html">
              <span class="en">Administering In-app Billing</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_reference.html">
              <span class="en">In-app Billing Reference</span></a>
          </li>
        </ul>
      </li>
      <li><a href="../../../guide/appendix/market-filters.html">
          <span class="en">Market Filters</span></a>
      </li>
      <li><a href="../../../guide/market/publishing/multiple-apks.html">
          <span class="en">Multiple APK Support</span></a>
      </li>
    </ul>
  </li>


  <li>
    <h2><span class="en">Developing</span>
               <span class="de" style="display:none">Entwicklung</span>
               <span class="es" style="display:none">Desarrollo</span>
               <span class="fr" style="display:none">Développement</span>
               <span class="it" style="display:none">Sviluppo</span>
               <span class="ja" style="display:none">開発</span>
               <span class="zh-CN" style="display:none">开发</span>
               <span class="zh-TW" style="display:none">開發</span>
    </h2>
    <ul>
  <!--<li><a href="">Developing for Android</a></li>
      signing, upgrading, selecting a package name, select device profile, touch, trackball, dpad available, etc. -->
      <li>
        <a href="../../../guide/developing/index.html">
        <span class="en">Introduction</span></a>
      </li>

      <li class="toggle-list">
        <div>
           <a href="../../../guide/developing/devices/index.html">
                <span class="en">Managing Virtual Devices</span>
            </a>
        </div>
        <ul>
          <li>
            <a href="../../../guide/developing/devices/managing-avds.html">
              <span class="en">With AVD Manager</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/devices/managing-avds-cmdline.html">
              <span class="en">From the Command Line</span>
            </a>
          </li>
          <li>
           <a href="../../../guide/developing/devices/emulator.html">
                <span class="en">Using the Android Emulator</span>
            </a>
          </li>
        </ul>
      </li>
      <li>
        <a href="../../../guide/developing/device.html">
          <span class="en">Using Hardware Devices</span>
        </a>
      </li>

      <li class="toggle-list">
        <div>
          <a href="../../../guide/developing/projects/index.html">
            <span class="en">Managing Projects</span>
          </a>
        </div>
        <ul>
          <li>
            <a href="../../../guide/developing/projects/projects-eclipse.html">
              <span class="en">From Eclipse with ADT</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/projects/projects-cmdline.html">
                <span class="en">From the Command Line</span>
            </a>
          </li>
        </ul>
      </li>

      <li class="toggle-list">
        <div>
          <a href="../../../guide/developing/building/index.html">
            <span class="en">Building and Running</span>
          </a>
        </div>
        <ul>
          <li><a href="../../../guide/developing/building/building-eclipse.html">
            <span class="en">From Eclipse with ADT</span>
          </a></li>
          <li><a href="../../../guide/developing/building/building-cmdline.html">
            <span class="en">From the Command Line</span></a></li>
        </ul>
      </li>

      <li class="toggle-list">
        <div>
          <a href="../../../guide/developing/debugging/index.html">
            <span class="en">Debugging</span>
          </a>
        </div>
        <ul>
          <li>
            <a href="../../../guide/developing/debugging/debugging-projects.html">
                <span class="en">From Eclipse with ADT</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-projects-cmdline.html">
                <span class="en">From Other IDEs</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/ddms.html">
              <span class="en">Using DDMS</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-log.html">
                <span class="en">Reading and Writing Logs</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-ui.html">
                <span class="en">Debugging and Profiling UIs</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-tracing.html">
                <span class="en">Profiling with Traceview and dmtracedump</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-devtools.html">
                <span class="en">Using the Dev Tools App</span>
            </a>
          </li>
        </ul>
      </li>

      <li class="toggle-list">
           <div>
                <a href="../../../guide/developing/testing/index.html">
                   <span class="en">Testing</span>
               </a>
           </div>
           <ul>
              <li>
                <a href="../../../guide/developing/testing/testing_eclipse.html">
                  <span class="en">From Eclipse with ADT</span>
                </a>
              </li>

              <li>
                <a href="../../../guide/developing/testing/testing_otheride.html">
                  <span class="en">From Other IDEs</span>
                </a>
              </li>
           </ul>
         </li>

         <li class="toggle-list">
        <div><a href="../../../guide/developing/tools/index.html">
            <span class="en">Tools</span>
          </a></div>
        <ul>
          <li><a href="../../../guide/developing/tools/adb.html">adb</a></li>
          <li><a href="../../../guide/developing/tools/adt.html">ADT</a></li>
          <li><a href="../../../guide/developing/tools/android.html">android</a></li>
          <li><a href="../../../guide/developing/tools/bmgr.html">bmgr</a>
          <li><a href="../../../guide/developing/tools/dmtracedump.html">dmtracedump</a></li>
          <li><a href="../../../guide/developing/tools/draw9patch.html">Draw
          9-Patch</a></li>
          <li><a href="../../../guide/developing/tools/emulator.html">Emulator</a></li>
          <li><a href="../../../guide/developing/tools/etc1tool.html">etc1tool</a></li>
          <li><a href="../../../guide/developing/tools/hierarchy-viewer.html">Hierarchy Viewer</a></li>
          <li><a href="../../../guide/developing/tools/hprof-conv.html">hprof-conv</a></li>
          <li><a href="../../../guide/developing/tools/layoutopt.html">layoutopt</a></li>
          <li><a href="../../../guide/developing/tools/logcat.html">logcat</a></li>
          <li><a href="../../../guide/developing/tools/mksdcard.html">mksdcard</a></li>
          <li><a href="../../../guide/developing/tools/monkey.html">Monkey</a></li>
          <li class="toggle-list">
            <div><a href="../../../guide/developing/tools/monkeyrunner_concepts.html">
              <span class="en">monkeyrunner</span>
            </a></div>
            <ul>
              <li><a href="../../../guide/developing/tools/MonkeyDevice.html">
                <span class="en">MonkeyDevice</span>
                </a></li>
              <li><a href="../../../guide/developing/tools/MonkeyImage.html">
                <span class="en">MonkeyImage</span>
                </a></li>
              <li><a href="../../../guide/developing/tools/MonkeyRunner.html">
                <span class="en">MonkeyRunner</span>
                </a></li>
            </ul>
          </li>
          <li><a href="../../../guide/developing/tools/proguard.html">ProGuard</a></li>
          <li><a href="../../../guide/developing/tools/adb.html#sqlite">sqlite3</a></li>
          <li><a href="../../../guide/developing/tools/traceview.html">Traceview</a></li>
          <li><a href="../../../guide/developing/tools/zipalign.html">zipalign</a></li>
        </ul>
      </li>
    </ul>
  </li>

  <li>
    <h2><span class="en">Publishing</span>
        <span class="de" style="display:none">Veröffentlichung</span>
        <span class="es" style="display:none">Publicación</span>
        <span class="fr" style="display:none">Publication</span>
        <span class="it" style="display:none">Pubblicazione</span>
        <span class="ja" style="display:none">公開</span>
        <span class="zh-CN" style="display:none">发布</span>
        <span class="zh-TW" style="display:none">發佈</span>
    </h2>
    <ul>
      <li><a href="../../../guide/publishing/app-signing.html">
            <span class="en">Signing Your Applications</span>
            <span class="de" style="display:none">Signieren Ihrer Anwendungen</span>
            <span class="es" style="display:none">Firma de aplicaciones</span>
            <span class="fr" style="display:none">Attribution de votre signature <br />à vos applications</span>
            <span class="it" style="display:none">Firma delle applicazioni</span>
            <span class="ja" style="display:none">アプリケーションへの署名</span>
            <span class="zh-CN" style="display:none">应用程序签名</span>
            <span class="zh-TW" style="display:none">簽署應用程式</span>
          </a></li>
      <li><a href="../../../guide/publishing/versioning.html">
            <span class="en">Versioning Your Applications</span>
            <span class="de" style="display:none">Versionsverwaltung für Ihre <br />Anwendungen</span>
            <span class="es" style="display:none">Versiones de las aplicaciones</span>
            <span class="fr" style="display:none">Attribution d'une version à vos applications</span>
            <span class="it" style="display:none">Controllo versioni delle applicazioni</span>
            <span class="ja" style="display:none">アプリケーションのバージョニング</span>
            <span class="zh-CN" style="display:none">应用程序版本控制</span>
            <span class="zh-TW" style="display:none">應用程式版本設定</span>
          </a></li>
      <li><a href="../../../guide/publishing/preparing.html">
            <span class="en">Preparing to Publish</span>
            <span class="de" style="display:none">Vorbereitung auf die Veröffentlichung</span>
            <span class="es" style="display:none">Publicación de aplicaciones</span>
            <span class="fr" style="display:none">Préparation à la publication</span>
            <span class="it" style="display:none">Preparativi per la pubblicazione</span>
            <span class="ja" style="display:none">公開の準備</span>
            <span class="zh-CN" style="display:none">准备发布</span>
            <span class="zh-TW" style="display:none">準備發佈</span>
          </a></li>
      <li><a href="../../../guide/publishing/publishing.html">
            <span class="en">Publishing on Android Market</span>
          </a></li>
    </ul>
  </li>

  <li>
    <h2><span class="en">Best Practices</span>
               <span class="de" style="display:none">Bewährte Verfahren</span>
               <span class="es" style="display:none">Prácticas recomendadas</span>
               <span class="fr" style="display:none">Meilleures pratiques</span>
               <span class="it" style="display:none">Best practice</span>
               <span class="ja" style="display:none">ベスト プラクティス</span>
               <span class="zh-CN" style="display:none">最佳实践</span>
               <span class="zh-TW" style="display:none">最佳實務</span>
    </h2>
    <ul>
      <li><a href="../../../guide/practices/compatibility.html">
            <span class="en">Compatibility</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/practices/screens_support.html">
          <span class="en">Supporting Multiple Screens</span>
        </a></div>
        <ul>
          <li><a href="../../../guide/practices/screens-distribution.html">
            <span class="en">Distributing to Specific Screens</span>
          </a></li>
          <li><a href="../../../guide/practices/screen-compat-mode.html">
            <span class="en">Screen Compatibility Mode</span>
          </a></li>
          <li><a href="../../../guide/practices/screens-support-1.5.html">
            <span class="en">Strategies for Android 1.5</span>
          </a></li>
        </ul>
      </li>
      <li><a href="../../../guide/practices/optimizing-for-3.0.html">
            <span class="en">Optimizing Apps for Android 3.0</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/practices/ui_guidelines/index.html">
               <span class="en">UI Guidelines</span>
             </a></div>
        <ul>
          <li class="toggle-list">
            <div><a href="../../../guide/practices/ui_guidelines/icon_design.html">
                   <span class="en">Icon Design <span class="new">updated</span></span>
                 </a></div>
            <ul>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_launcher.html">
                    <span class="en">Launcher Icons <span class="new">updated</span></span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_menu.html">
                    <span class="en">Menu Icons</span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_action_bar.html">
                    <span class="en">Action Bar Icons <span class="new">new!</span></span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_status_bar.html">
                    <span class="en">Status Bar Icons <span class="new">updated</span></span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_tab.html">
                    <span class="en">Tab Icons</span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_dialog.html">
                    <span class="en">Dialog Icons</span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_list.html">
                    <span class="en">List View Icons</span>
                  </a></li>
            </ul>
          </li>
          <li><a href="../../../guide/practices/ui_guidelines/widget_design.html">
                <span class="en">App Widget Design <span class="new">updated</span></span>
              </a></li>
          <li><a href="../../../guide/practices/ui_guidelines/activity_task_design.html">
                <span class="en">Activity and Task Design</span>
              </a></li>
          <li><a href="../../../guide/practices/ui_guidelines/menu_design.html">
                <span class="en">Menu Design</span>
              </a></li>
        </ul>
      </li>
      </ul>
      <ul>
      <li><a href="../../../guide/practices/design/accessibility.html">
            <span class="en">Designing for Accessibility</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/practices/design/performance.html">
            <span class="en">Designing for Performance</span>
          </a></div>
        <ul>
          <li><a href="../../../guide/practices/design/jni.html">
                <span class="en">JNI Tips</span>
              </a></li>
        </ul>
      </li>
      <li><a href="../../../guide/practices/design/responsiveness.html">
            <span class="en">Designing for Responsiveness</span>
          </a></li>
      <li><a href="../../../guide/practices/design/seamlessness.html">
            <span class="en">Designing for Seamlessness</span>
          </a></li>
    </ul>
  </li>

  <li>
    <h2><span class="en">Web Applications</span>
    </h2>
    <ul>
      <li><a href="../../../guide/webapps/index.html">
            <span class="en">Web Apps Overview</span>
          </a></li>
      <li><a href="../../../guide/webapps/targeting.html">
            <span class="en">Targeting Screens from Web Apps</span>
          </a></li>
      <li><a href="../../../guide/webapps/webview.html">
            <span class="en">Building Web Apps in WebView</span>
          </a></li>
      <li><a href="../../../guide/webapps/debugging.html">
            <span class="en">Debugging Web Apps</span>
          </a></li>
      <li><a href="../../../guide/webapps/best-practices.html">
            <span class="en">Best Practices for Web Apps</span>
          </a></li>
    </ul>
  </li>

  <li>
    <h2><span class="en">Appendix</span>
               <span class="de" style="display:none">Anhang</span>
               <span class="es" style="display:none">Apéndice</span>
               <span class="fr" style="display:none">Annexes</span>
               <span class="it" style="display:none">Appendice</span>
               <span class="ja" style="display:none">付録</span>
               <span class="zh-CN" style="display:none">附录</span>
               <span class="zh-TW" style="display:none">附錄</span>
    </h2>
    <ul>
      <li><a href="../../../guide/appendix/api-levels.html">
            <span class="en">Android API Levels</span>
          </a></li>
      <li><a href="../../../guide/appendix/install-location.html">
            <span class="en">App Install Location</span>
          </a></li>
      <li><a href="../../../guide/appendix/media-formats.html">
            <span class="en">Supported Media Formats <span class="new">updated</span></span>
          </a></li>
      <li><a href="../../../guide/appendix/g-app-intents.html">
            <span class="en">Intents List: Google Apps</span>
          </a></li>
      <li><a href="../../../guide/developing/tools/aidl.html">AIDL</a></li>
      <li><a href="../../../guide/appendix/glossary.html">
            <span class="en">Glossary</span>
          </a></li>
    </ul>
  </li>

</ul>

<script type="text/javascript">
<!--
    buildToggleLists();
    changeNavLang(getLangPref());
//-->
</script>

      </div>
    </div> <!-- end side-nav -->
    <script>
      addLoadEvent(function() {
        scrollIntoView("devdoc-nav");
        });
    </script>




<div class="g-unit" id="doc-content"><a name="top"></a>

<div id="jd-header" class="guide-header">
  <span class="crumb">
    
      <a href="available-resources.html">Resource Types</a> >
    
  </span>
<h1>Drawable Resources</h1>
</div>

  <div id="jd-content">

    <div class="jd-descr">
    <div id="qv-wrapper">
  <div id="qv">
    <h2>See also</h2>
    <ol>
      <li><a href="../../../guide/topics/graphics/2d-graphics.html">2D Graphics</a></li>
    </ol>
  </div>
</div>

<p>A drawable resource is a general concept for a graphic that can be drawn to the screen and which
you can retrieve with APIs such as <code><a href="../../../reference/android/content/res/Resources.html#getDrawable(int)">getDrawable(int)</a></code> or apply
to another XML resource with attributes such as <code>android:drawable</code> and <code>android:icon</code>.
There are several different types of drawables:</p>
<dl>
  <dt><a href="#Bitmap">Bitmap File</a><dt>
    <dd>A bitmap graphic file (<code>.png</code>, <code>.jpg</code>, or <code>.gif</code>).
      Creates a <code><a href="../../../reference/android/graphics/drawable/BitmapDrawable.html">BitmapDrawable</a></code>.</dd>
  <dt><a href="#NinePatch">Nine-Patch File</a></dt>
    <dd>A PNG file with stretchable regions to allow image resizing based on content (<code>.9.png</code>). Creates a <code><a href="../../../reference/android/graphics/drawable/NinePatchDrawable.html">NinePatchDrawable</a></code>.</dd>
  <dt><a href="#LayerList">Layer List</a></dt>
    <dd>A Drawable that manages an array of other Drawables. These are drawn in array order, so the
element with the largest index is be drawn on top. Creates a <code><a href="../../../reference/android/graphics/drawable/LayerDrawable.html">LayerDrawable</a></code>.</dd>
  <dt><a href="#StateList">State List</a></dt>
    <dd>An XML file that references different bitmap graphics
    for different states (for example, to use a different image when a button is pressed).
    Creates a <code><a href="../../../reference/android/graphics/drawable/StateListDrawable.html">StateListDrawable</a></code>.</dd>
  <dt><a href="#LevelList">Level List</a></dt>
    <dd>An XML file that defines a drawable that manages a number of alternate Drawables, each
assigned a maximum numerical value. Creates a <code><a href="../../../reference/android/graphics/drawable/LevelListDrawable.html">LevelListDrawable</a></code>.</dd>
  <dt><a href="#Transition">Transition Drawable</a></dt>
    <dd>An XML file that defines a drawable that can cross-fade between two drawable resources.
Creates a <code><a href="../../../reference/android/graphics/drawable/TransitionDrawable.html">TransitionDrawable</a></code>.</dd>
  <dt><a href="#Inset">Inset Drawable</a></dt>
    <dd>An XML file that defines a drawable that insets another drawable by a specified distance.
This is useful when a View needs a background drawble that is smaller than the View's actual
bounds.</dd>
  <dt><a href="#Clip">Clip Drawable</a></dt>
    <dd>An XML file that defines a drawable that clips another Drawable based on this Drawable's
current level value. Creates a <code><a href="../../../reference/android/graphics/drawable/ClipDrawable.html">ClipDrawable</a></code>.</dd>
  <dt><a href="#Scale">Scale Drawable</a></dt>
    <dd>An XML file that defines a drawable that changes the size of another Drawable based on its
current level value.  Creates a <code><a href="../../../reference/android/graphics/drawable/ScaleDrawable.html">ScaleDrawable</a></code></dd>
  <dt><a href="#Shape">Shape Drawable</a></dt>
    <dd>An XML file that defines a geometric shape, including colors and gradients.
    Creates a <code><a href="../../../reference/android/graphics/drawable/ShapeDrawable.html">ShapeDrawable</a></code>.</dd>
</dl>

<p>Also see the <a href="animation-resource.html">Animation Resource</a> document for how to
create an <code><a href="../../../reference/android/graphics/drawable/AnimationDrawable.html">AnimationDrawable</a></code>.</p>

<p class="note"><strong>Note:</strong> A <a
href="../../../guide/topics/resources/more-resources.html#Color">color resource</a> can also be
used as a drawable in XML. For example, when creating a <a href="#StateList">state list
drawable</a>, you can reference a color resource for the <code>android:drawable</code> attribute (<code>android:drawable="@color/green"</code>).</p>




<h2 id="Bitmap">Bitmap</h2>

<p>A bitmap image. Android supports bitmap files in a three formats:
<code>.png</code> (preferred), <code>.jpg</code> (acceptable), <code>.gif</code> (discouraged).</p>

<p>You can reference a bitmap file directly, using the filename as the resource ID, or create an
alias resource ID in XML.</p>

<p class="note"><strong>Note:</strong> Bitmap files may be automatically optimized with lossless
image compression by the <code>aapt</code> tool during the build process. For
example, a true-color PNG that does not require more than 256 colors may be converted to an 8-bit
PNG with a color palette. This will result in an image of equal quality but which requires less
memory. So be aware that the image binaries placed in this directory can change during the build. If
you plan on reading an image as a bit stream in order to convert it to a bitmap, put your images in
the <code>res/raw/</code> folder instead, where they will not be optimized.</p>


<h3 id="BitmapFile">Bitmap File</h3>

<p>A bitmap file is a <code>.png</code>, <code>.jpg</code>, or <code>.gif</code> file. Android creates a <code><a href="../../../reference/android/graphics/drawable/Drawable.html">Drawable</a></code>
resource for any of these files when you save them in the <code>res/drawable/</code> directory.</p>

<dl class="xml">

<dt>file location:</dt>
<dd><code>res/drawable/<em>filename</em>.png</code> (<code>.png</code>, <code>.jpg</code>, or <code>.gif</code>)<br/>
The filename is used as the resource ID.</dd>

<dt>compiled resource datatype:</dt>
<dd>Resource pointer to a <code><a href="../../../reference/android/graphics/drawable/BitmapDrawable.html">BitmapDrawable</a></code>.</dd>

<dt>resource reference:</dt>
<dd>
In Java: <code>R.drawable.<em>filename</em></code></li><br/>
In XML: <code>@[<em>package</em>:]drawable/<em>filename</em></code>
</dd>

<dt>example:</dt>

<dd>With an image saved at <code>res/drawable/myimage.png</code>, this layout XML applies
the image to a View:
<pre>
&lt;ImageView
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:src="@drawable/myimage" />
</pre>
<p>The following application code retrieves the image as a <code><a href="../../../reference/android/graphics/drawable/Drawable.html">Drawable</a></code>:</p>
<pre>
Resources res = <code><a href="../../../reference/android/content/Context.html#getResources()">getResources()</a></code>;
Drawable drawable = res.<code><a href="../../../reference/android/content/res/Resources.html#getDrawable(int)">getDrawable</a></code>(R.drawable.myimage);
</pre>
</dd>

<dt>see also:</dt>
<dd>
<ul>
  <li><a href="../../../guide/topics/graphics/2d-graphics.html">2D Graphics</a></li>
  <li><code><a href="../../../reference/android/graphics/drawable/BitmapDrawable.html">BitmapDrawable</a></code></li>
</ul>
</dd>

</dl>




<h3 id="XmlBitmap">XML Bitmap</h3>

<p>An XML bitmap is a resource defined in XML that points to a bitmap file. The effect is an alias for a
raw bitmap file. The XML can specify additional properties for the bitmap such as dithering and tiling.</p>

<p class="note"><strong>Note:</strong> You can use a <code>&lt;bitmap&gt;</code> element as a child of
an <code>&lt;item&gt;</code> element. For
example, when creating a <a href="#StateList">state list</a> or <a href="#LayerList">layer list</a>,
you can exclude the <code>android:drawable</code>
attribute from an <code>&lt;item&gt;</code> element and nest a <code>&lt;bitmap&gt;</code> inside it
that defines the drawable item.</p>

<dl class="xml">

<dt>file location:</dt>
<dd><code>res/drawable/<em>filename</em>.xml</code><br/>
The filename is used as the resource ID.</dd>

<dt>compiled resource datatype:</dt>
<dd>Resource pointer to a <code><a href="../../../reference/android/graphics/drawable/BitmapDrawable.html">BitmapDrawable</a></code>.</dd>

<dt>resource reference:</dt>
<dd>
In Java: <code>R.drawable.<em>filename</em></code></li><br/>
In XML: <code>@[<em>package</em>:]drawable/<em>filename</em></code>
</dd>

<dt>syntax:</dt>
<dd>
<pre class="stx">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;<a href="#bitmap-element">bitmap</a>
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@[package:]drawable/<em>drawable_resource</em>"
    android:antialias=["true" | "false"]
    android:dither=["true" | "false"]
    android:filter=["true" | "false"]
    android:gravity=["top" | "bottom" | "left" | "right" | "center_vertical" |
                      "fill_vertical" | "center_horizontal" | "fill_horizontal" |
                      "center" | "fill" | "clip_vertical" | "clip_horizontal"]
    android:tileMode=["disabled" | "clamp" | "repeat" | "mirror"] /&gt;
</pre>
</dd>


<dt>elements:</dt>
<dd>
<dl class="tag-list">

  <dt id="bitmap-element"><code>&lt;bitmap&gt;</code></dt>
    <dd>Defines the bitmap source and its properties.
      <p class="caps">attributes:</p>
      <dl class="atn-list">
        <dt><code>xmlns:android</code></dt>
          <dd><em>String</em>. Defines the XML namespace, which must be
          <code>"http://schemas.android.com/apk/res/android"</code>. This is required only if the
<code>&lt;bitmap&gt;</code> is the root element&mdash;it is not needed when the
<code>&lt;bitmap&gt;</code> is nested inside an <code>&lt;item&gt;</code>.</dd>
        <dt><code>android:src</code></dt>
          <dd><em>Drawable resource</em>. <strong>Required</strong>. Reference to a drawable
resource.</dd>
        <dt><code>android:antialias</code></dt>
          <dd><em>Boolean</em>. Enables or disables antialiasing.</dd>
        <dt><code>android:dither</code></dt>
          <dd><em>Boolean</em>. Enables or disables dithering of the bitmap if the bitmap does not
have the same pixel configuration as the screen (for instance: a ARGB 8888 bitmap with an RGB 565
screen).</dd>
        <dt><code>android:filter</code></dt>
          <dd><em>Boolean</em>. Enables or disables bitmap filtering. Filtering is used when the
bitmap is shrunk or stretched to smooth its apperance.</dd>
        <dt><code>android:gravity</code></dt>
          <dd><em>Keyword</em>. Defines the gravity for the bitmap. The gravity indicates where to
position the drawable in its container if the bitmap is smaller than the container.
            <p>Must be one or more (separated by '|') of the following constant values:</p>
<table>
<tr><th>Value</th><th>Description</th></tr>
<tr><td><code>top</code></td>
<td>Put the object at the top of its container, not changing its size.</td></tr>
<tr><td><code>bottom</code></td>
<td>Put the object at the bottom of its container, not changing its size. </td></tr>
<tr><td><code>left</code></td>
<td>Put the object at the left edge of its container, not changing its size. </td></tr>
<tr><td><code>right</code></td>
<td>Put the object at the right edge of its container, not changing its size. </td></tr>
<tr><td><code>center_vertical</code></td>
<td>Place object in the vertical center of its container, not changing its size. </td></tr>
<tr><td><code>fill_vertical</code></td>
<td>Grow the vertical size of the object if needed so it completely fills its container. </td></tr>
<tr><td><code>center_horizontal</code></td>
<td>Place object in the horizontal center of its container, not changing its size. </td></tr>
<tr><td><code>fill_horizontal</code></td>
<td>Grow the horizontal size of the object if needed so it completely fills its container.
</td></tr>
<tr><td><code>center</code></td>
<td>Place the object in the center of its container in both the vertical and horizontal axis, not
changing its size. </td></tr>
<tr><td><code>fill</code></td>
<td>Grow the horizontal and vertical size of the object if needed so it completely fills its
container. This is the default.</td></tr>
<tr><td><code>clip_vertical</code></td>
<td>Additional option that can be set to have the top and/or bottom edges of the child clipped to
its container's bounds. The clip is based on the vertical gravity: a top gravity clips the
bottom edge, a bottom gravity clips the top edge, and neither clips both edges.
</td></tr>
<tr><td><code>clip_horizontal</code></td>
<td>Additional option that can be set to have the left and/or right edges of the child clipped to
its container's bounds. The clip is based on the horizontal gravity: a left gravity clips
the right edge, a right gravity clips the left edge, and neither clips both edges.
</td></tr>
</table>
          </dd>
        <dt><code>android:tileMode</code></dt>
          <dd><em>Keyword</em>. Defines the tile mode. When the tile mode is enabled, the bitmap is
repeated. Gravity is ignored when the tile mode is enabled.
            <p>Must be one of the following constant values:</p>
<table>
<tr><th>Value</th><th>Description</th></tr>
<tr><td><code>disabled</code></td>
<td>Do not tile the bitmap. This is the default value.</td></tr>
<tr><td><code>clamp</code></td>
<td>Replicates the edge color if the shader draws outside of its original bounds</td></tr>
<tr><td><code>repeat</code></td>
<td>Repeats the shader's image horizontally and vertically.</td></tr>
<tr><td><code>mirror</code></td>
<td>Repeats the shader's image horizontally and vertically, alternating mirror images so that
adjacent images always seam.</td></tr>
</table>

          </dd>
      </dl>
    </dd>

</dl>
</dd> <!-- end  elements and attributes -->

<dt>example:</dt>
<dd>
<pre>
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/icon"
    android:tileMode="repeat" /&gt;
</pre>

</dd>

<dt>see also:</dt>
<dd>
<ul>
  <li><code><a href="../../../reference/android/graphics/drawable/BitmapDrawable.html">BitmapDrawable</a></code></li>
  <li><a href="../../../guide/topics/resources/providing-resources.html#AliasResources">Creating
alias resources</a>
</ul>
</dd>

</dl>






<h2 id="NinePatch">Nine-Patch</h2>

<p>A <code><a href="../../../reference/android/graphics/NinePatch.html">NinePatch</a></code> is a PNG image in which you can define stretchable regions
that Android scales when content within the View exceeds the normal image bounds. You
typically assign this type of image as the background of a View that has at least one dimension set
to <code>"wrap_content"</code>, and when the View grows to accomodate the content, the Nine-Patch image
is also scaled to match the size of the View. An example use of a Nine-Patch image is the
background used by Android's standard <code><a href="../../../reference/android/widget/Button.html">Button</a></code> widget, which must stretch to
accommodate the text (or image) inside the button.</p>

<p>Same as with a normal <a href="#Bitmap">bitmap</a>, you can reference a Nine-Patch file directly
or from a resource defined by XML.</p>

<p>For a complete discussion about how to create a Nine-Patch file with stretchable regions,
see the <a href="../../../guide/topics/graphics/2d-graphics.html#nine-patch">2D Graphics</a>
document.</p>


<h3 id="NinePatchFile">Nine-Patch File</h3>

<dl class="xml">

<dt>file location:</dt>
<dd><code>res/drawable/<em>filename</em>.9.png</code><br/>
The filename is used as the resource ID.</dd>

<dt>compiled resource datatype:</dt>
<dd>Resource pointer to a <code><a href="../../../reference/android/graphics/drawable/NinePatchDrawable.html">NinePatchDrawable</a></code>.</dd>

<dt>resource reference:</dt>

<dd>
In Java: <code>R.drawable.<em>filename</em></code><br/>
In XML: <code>@[<em>package</em>:]drawable/<em>filename</em></code>
</dd>

<dt>example:</dt>

<dd>With an image saved at <code>res/drawable/myninepatch.9.png</code>, this layout XML
applies the Nine-Patch to a View:
<pre>
&lt;Button
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:background="@drawable/myninepatch" />
</pre>
</dd>

<dt>see also:</dt>

<dd>
<ul>
  <li><a href="../../../guide/topics/graphics/2d-graphics.html#nine-patch">2D Graphics</a></li>
  <li><code><a href="../../../reference/android/graphics/drawable/NinePatchDrawable.html">NinePatchDrawable</a></code></li>
</ul>
</dd>

</dl>




<h3 id="NinePatchXml">XML Nine-Patch</h3>

<p>An XML Nine-Patch is a resource defined in XML that points to a Nine-Patch file. The XML can
specify dithering for the image.</p>

<dl class="xml">

<dt>file location:</dt>
<dd><code>res/drawable/<em>filename</em>.xml</code><br/>
The filename is used as the resource ID.</dd>

<dt>compiled resource datatype:</dt>
<dd>Resource pointer to a <code><a href="../../../reference/android/graphics/drawable/NinePatchDrawable.html">NinePatchDrawable</a></code>.</dd>

<dt>resource reference:</dt>

<dd>
In Java: <code>R.drawable.<em>filename</em></code><br/>
In XML: <code>@[<em>package</em>:]drawable/<em>filename</em></code>
</dd>


<dt>syntax:</dt>

<dd>
<pre class="stx">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;<a href="#ninepatch-element">nine-patch</a>
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@[package:]drawable/<em>drawable_resource</em>"
    android:dither=["true" | "false"] /&gt;
</pre>
</dd>


<dt>elements:</dt>

<dd>
<dl class="tag-list">

  <dt id="ninepatch-element"><code>&lt;nine-patch&gt;</code></dt>
    <dd>Defines the Nine-Patch source and its properties.
      <p class="caps">attributes:</p>
      <dl class="atn-list">
        <dt><code>xmlns:android</code></dt>
          <dd><em>String</em>. <strong>Required.</strong> Defines the XML namespace, which must be
          <code>"http://schemas.android.com/apk/res/android"</code>.
        <dt><code>android:src</code></dt>
          <dd><em>Drawable resource</em>. <strong>Required</strong>. Reference to a Nine-Patch
file.</dd>
        <dt><code>android:dither</code></dt>
          <dd><em>Boolean</em>. Enables or disables dithering of the bitmap if the bitmap does not
have the same pixel configuration as the screen (for instance: a ARGB 8888 bitmap with an RGB 565
screen).</dd>
      </dl>
    </dd>
</dl>
</dd>


<dt>example:</dt>

<dd>
<pre class="stx">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/myninepatch"
    android:dither="false" /&gt;
</pre>
</dd>
</dl>






<h2 id="LayerList">Layer List</h2>

<p>A <code><a href="../../../reference/android/graphics/drawable/LayerDrawable.html">LayerDrawable</a></code> is a drawable object
that manages an array of other drawables. Each drawable in the list is drawn in the order of the
list&mdash;the last drawable in the list is drawn on top.</p>

<p>Each drawable is represented by an <code>&lt;item&gt;</code> element inside a single <code>&lt;layer-list&gt;</code> element.</p>

<dl class="xml">

<dt>file location:</dt>
<dd><code>res/drawable/<em>filename</em>.xml</code><br/>
The filename is used as the resource ID.</dd>

<dt>compiled resource datatype:</dt>
<dd>Resource pointer to a <code><a href="../../../reference/android/graphics/drawable/LayerDrawable.html">LayerDrawable</a></code>.</dd>

<dt>resource reference:</dt>

<dd>
In Java: <code>R.drawable.<em>filename</em></code><br/>
In XML: <code>@[<em>package</em>:]drawable/<em>filename</em></code>
</dd>

<dt>syntax:</dt>

<dd>
<pre class="stx">
&lt;?xml version="1.0" encoding="utf-8"?>
&lt;<a href="#layerlist-element">layer-list</a>
    xmlns:android="http://schemas.android.com/apk/res/android" &gt;
    &lt;<a href="#layerlist-item-element">item</a>
        android:drawable="@[package:]drawable/<em>drawable_resource</em>"
        android:id="@[+][<em>package</em>:]id/<i>resource_name</i>"
        android:top="<em>dimension</em>"
        android:right="<em>dimension</em>"
        android:bottom="<em>dimension</em>"
        android:left="<em>dimension</em>" /&gt;
&lt;/layer-list>
</pre>
</dd>

<dt>elements:</dt>

<dd>
<dl class="tag-list">

  <dt id="layerlist-element"><code>&lt;layer-list&gt;</code></dt>
    <dd><strong>Required.</strong> This must be the root element. Contains one or more <code>&lt;item></code> elements.
      <p class="caps">attributes:</p>
      <dl class="atn-list">
        <dt><code>xmlns:android</code></dt>
          <dd><em>String</em>. <strong>Required.</strong> Defines the XML namespace, which must be
          <code>"http://schemas.android.com/apk/res/android"</code>.
      </dl>
    </dd>
  <dt id="layerlist-item-element"><code>&lt;item&gt;</code></dt>
    <dd>Defines a drawable to place in the layer drawable, in a position defined by its attributes.
Must be a child of a <code>&lt;selector&gt;</code> element. Accepts child <code>&lt;bitmap&gt;</code>
elements.
      <p class="caps">attributes:</p>
      <dl class="atn-list">
        <dt><code>android:drawable</code></dt>
          <dd><em>Drawable resource</em>. <strong>Required</strong>. Reference to a drawable
resource.</dd>
        <dt><code>android:id</code></dt>
          <dd><em>Resource ID</em>. A unique resource ID for this drawable. To create a new resource
ID for this item, use the form:
<code>"@+id/<em>name</em>"</code>. The plus symbol indicates that this should be created as a new
ID. You can use this identifier to
retrieve and modify the drawable with <code><a href="../../../reference/android/view/View.html#findViewById(int)">View.findViewById()</a></code> or <code><a href="../../../reference/android/app/Activity.html#findViewById(int)">Activity.findViewById()</a></code>.</dd>
        <dt><code>android:top</code></dt>
          <dd><em>Integer</em>. The top offset in pixels.</dd>
        <dt><code>android:right</code></dt>
          <dd><em>Integer</em>. The right offset in pixels.</dd>
        <dt><code>android:bottom</code></dt>
          <dd><em>Integer</em>. The bottom offset in pixels.</dd>
        <dt><code>android:left</code></dt>
          <dd><em>Integer</em>. The left offset in pixels.</dd>
      </dl>
      <p>All drawable items are scaled to fit the size of the containing View, by default. Thus,
placing your images in a layer list at different positions might increase the size of the View and
some images scale as appropriate. To avoid
scaling items in the list, use a <code>&lt;bitmap&gt;</code> element inside the <code>&lt;item&gt;</code> element to specify the drawable and define the gravity to something that does not
scale, such as <code>"center"</code>. For example, the following <code>&lt;item&gt;</code> defines an item
that scales to fit its container View:</p>
<pre>
&lt;item android:drawable="@drawable/image" /&gt;
</pre>

<p>To avoid scaling, the following example uses a <code>&lt;bitmap&gt;</code> element with centered
gravity:</p>
<pre>
&lt;item&gt;
  &lt;bitmap android:src="<b>@drawable/image</b>"
          android:gravity="center" /&gt;
&lt;/item&gt;
</pre>
    </dd>

</dl>
</dd> <!-- end  elements and attributes -->

<dt>example:</dt>

<dd>XML file saved at <code>res/drawable/layers.xml</code>:
<pre>
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;item&gt;
      &lt;bitmap android:src="@drawable/android_red"
        android:gravity="center" /&gt;
    &lt;/item&gt;
    &lt;item android:top="10dp" android:left="10dp"&gt;
      &lt;bitmap android:src="@drawable/android_green"
        android:gravity="center" /&gt;
    &lt;/item&gt;
    &lt;item android:top="20dp" android:left="20dp"&gt;
      &lt;bitmap android:src="@drawable/android_blue"
        android:gravity="center" /&gt;
    &lt;/item&gt;
&lt;/layer-list&gt;
</pre>
<p>Notice that this example uses a nested <code>&lt;bitmap&gt;</code> element to define the drawable
resource for each item with a "center" gravity. This ensures that none of the images are scaled to
fit the size of the container, due to resizing caused by the offset images.</p>

<p>This layout XML applies the drawable to a View:</p>
<pre>
&lt;ImageView
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:src="@drawable/layers" /&gt;
</pre>

<p>The result is a stack of increasingly offset images:</p>
<img src="../../../images/resources/layers.png" alt="" />
</dd> <!-- end example -->

<dt>see also:</dt>
<dd>
<ul>
  <li><code><a href="../../../reference/android/graphics/drawable/LayerDrawable.html">LayerDrawable</a></code></li>
</ul>
</dd>

</dl>








<h2 id="StateList">State List</h2>

<p>A <code><a href="../../../reference/android/graphics/drawable/StateListDrawable.html">StateListDrawable</a></code> is a drawable object defined in XML
that uses a several different images to represent the same graphic, depending on the state of
the object. For example, a <code><a href="../../../reference/android/widget/Button.html">Button</a></code> widget can exist in one of several different states (pressed, focused,
or niether) and, using a state list drawable, you can provide a different background image for each
state.</p>

<p>You can describe the state list in an XML file. Each graphic is represented by an <code>&lt;item></code> element inside a single <code>&lt;selector></code> element. Each <code>&lt;item></code>
uses various attributes to describe the state in which it should be used as the graphic for the
drawable.</p>

<p>During each state change, the state list is traversed top to bottom and the first item that
matches the current state is used&mdash;the selection is <em>not</em> based on the "best
match," but simply the first item that meets the minimum criteria of the state.</p>

<dl class="xml">

<dt>file location:</dt>
<dd><code>res/drawable/<em>filename</em>.xml</code><br/>
The filename is used as the resource ID.</dd>

<dt>compiled resource datatype:</dt>
<dd>Resource pointer to a <code><a href="../../../reference/android/graphics/drawable/StateListDrawable.html">StateListDrawable</a></code>.</dd>

<dt>resource reference:</dt>

<dd>
In Java: <code>R.drawable.<em>filename</em></code><br/>
In XML: <code>@[<em>package</em>:]drawable/<em>filename</em></code>
</dd>

<dt>syntax:</dt>

<dd>
<pre class="stx">
&lt;?xml version="1.0" encoding="utf-8"?>
&lt;<a href="#selector-element">selector</a> xmlns:android="http://schemas.android.com/apk/res/android"
    android:constantSize=["true" | "false"]
    android:dither=["true" | "false"]
    android:variablePadding=["true" | "false"] >
    &lt;<a href="#item-element">item</a>
        android:drawable="@[package:]drawable/<em>drawable_resource</em>"
        android:state_pressed=["true" | "false"]
        android:state_focused=["true" | "false"]
        android:state_hovered=["true" | "false"]
        android:state_selected=["true" | "false"]
        android:state_checkable=["true" | "false"]
        android:state_checked=["true" | "false"]
        android:state_enabled=["true" | "false"]
        android:state_window_focused=["true" | "false"] />
&lt;/selector>
</pre>
</dd>

<dt>elements:</dt>

<dd>
<dl class="tag-list">

  <dt id="selector-element"><code>&lt;selector&gt;</code></dt>
    <dd><strong>Required.</strong> This must be the root element. Contains one or more <code>&lt;item></code> elements.
      <p class="caps">attributes:</p>
      <dl class="atn-list">
        <dt><code>xmlns:android</code></dt>
          <dd><em>String</em>. <strong>Required.</strong> Defines the XML namespace, which must be
          <code>"http://schemas.android.com/apk/res/android"</code>.
        <dt><code>android:constantSize</code></dt>
          <dd><em>Boolean</em>. "true" if the drawable's reported internal size remains constant as the state
changes (the size is the maximum of all of the states); "false" if the size varies based on
the current state. Default is false.</dd>
        <dt><code>android:dither</code></dt>
          <dd><em>Boolean</em>. "true" to enable dithering of the bitmap if the bitmap does not have the same pixel
configuration as the screen (for instance, an ARGB 8888 bitmap with an RGB 565 screen); "false" to
disable dithering. Default is true.</dd>
        <dt><code>android:variablePadding</code></dt>
          <dd><em>Boolean</em>. "true" if the drawable's padding should change based on the current
state that is selected; "false" if the padding should stay the same (based on the maximum
padding of all the states). Enabling this feature requires that you deal with
performing layout when the state changes, which is often not supported. Default is false.</dd>
      </dl>
    </dd>
  <dt id="item-element"><code>&lt;item&gt;</code></dt>
    <dd>Defines a drawable to use during certain states, as described by its attributes. Must be a
child of a <code>&lt;selector&gt;</code> element.
      <p class="caps">attributes:</p>
      <dl class="atn-list">
        <dt><code>android:drawable</code></dt>
          <dd><em>Drawable resource</em>. <strong>Required</strong>. Reference to a drawable resource.</dd>
        <dt><code>android:state_pressed</code></dt>
          <dd><em>Boolean</em>. "true" if this item should be used when the object is pressed (such as when a button
is touched/clicked); "false" if this item should be used in the default, non-pressed state.</dd>
        <dt><code>android:state_focused</code></dt>
          <dd><em>Boolean</em>. "true" if this item should be used when the object is focused (such as when a button
is highlighted using the trackball/d-pad); "false" if this item should be used in the default,
non-focused state.</dd>
        <dt><code>android:state_hovered</code></dt>
          <dd><em>Boolean</em>. "true" if this item should be used when the object is being hovered
by a cursor; "false" if this item should be used in the default, non-hovered state. Often, this
drawable may be the same drawable used for the "focused" state.
          <p>Introduced in API level 14.</p></dd>
        <dt><code>android:state_selected</code></dt>
          <dd><em>Boolean</em>. "true" if this item should be used when the object is selected (such as when a
tab is opened); "false" if this item should be used when the object is not selected.</dd>
        <dt><code>android:state_checkable</code></dt>
          <dd><em>Boolean</em>. "true" if this item should be used when the object is checkable; "false" if this
item should be used when the object is not checkable. (Only useful if the object can
transition between a checkable and non-checkable widget.)</dd>
        <dt><code>android:state_checked</code></dt>
          <dd><em>Boolean</em>. "true" if this item should be used when the object is checked; "false" if it
should be used when the object is un-checked.</dd>
        <dt><code>android:state_enabled</code></dt>
          <dd><em>Boolean</em>. "true" if this item should be used when the object is enabled (capable of
receiving touch/click events); "false" if it should be used when the object is disabled.</dd>
        <dt><code>android:state_window_focused</code></dt>
          <dd><em>Boolean</em>. "true" if this item should be used when the application window has focus (the
application is in the foreground), "false" if this item should be used when the application
window does not have focus (for example, if the notification shade is pulled down or a dialog appears).</dd>
      </dl>
      <p class="note"><strong>Note:</strong> Remember that Android applies the first item in the state list that
matches the current state of the object. So, if the first item in the list contains
none of the state attributes above, then it is applied every time, which is why your
default value should always be last (as demonstrated in the following example).</p>
    </dd>

</dl>
</dd> <!-- end  elements and attributes -->

<dt>example:</dt>

<dd>XML file saved at <code>res/drawable/button.xml</code>:
<pre>
&lt;?xml version="1.0" encoding="utf-8"?>
&lt;selector xmlns:android="http://schemas.android.com/apk/res/android">
    &lt;item android:state_pressed="true"
          android:drawable="@drawable/button_pressed" /> &lt;!-- pressed --&gt;
    &lt;item android:state_focused="true"
          android:drawable="@drawable/button_focused" /> &lt;!-- focused --&gt;
    &lt;item android:state_hovered="true"
          android:drawable="@drawable/button_focused" /> &lt;!-- hovered --&gt;
    &lt;item android:drawable="@drawable/button_normal" /> &lt;!-- default --&gt;
&lt;/selector>
</pre>

<p>This layout XML applies the state list drawable to a Button:</p>
<pre>
&lt;Button
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:background="@drawable/button" />
</pre>
</dd> <!-- end example -->

<dt>see also:</dt>
<dd>
<ul>
  <li><code><a href="../../../reference/android/graphics/drawable/StateListDrawable.html">StateListDrawable</a></code></li>
</ul>
</dd>

</dl>








<h2 id="LevelList">Level List</h2>

<p>A Drawable that manages a number of alternate Drawables, each assigned a maximum numerical
value. Setting the level value of the drawable with <code><a href="../../../reference/android/graphics/drawable/Drawable.html#setLevel(int)">setLevel()</a></code> loads the drawable resource in the
level list that has a <code>android:maxLevel</code> value greater than or equal to the value
passed to the method.</p>

<dl class="xml">

<dt>file location:</dt>
<dd><code>res/drawable/<em>filename</em>.xml</code><br/>
The filename is used as the resource ID.</dd>

<dt>compiled resource datatype:</dt>
<dd>Resource pointer to a <code><a href="../../../reference/android/graphics/drawable/LevelListDrawable.html">LevelListDrawable</a></code>.</dd>

<dt>resource reference:</dt>

<dd>
In Java: <code>R.drawable.<em>filename</em></code><br/>
In XML: <code>@[<em>package</em>:]drawable/<em>filename</em></code>
</dd>

<dt>syntax:</dt>

<dd>
<pre class="stx">
&lt;?xml version="1.0" encoding="utf-8"?>
&lt;<a href="#levellist-element">level-list</a>
    xmlns:android="http://schemas.android.com/apk/res/android" &gt;
    &lt;<a href="#levellist-item-element">item</a>
        android:drawable="@drawable/<i>drawable_resource</i>"
        android:maxLevel="<i>integer</i>"
        android:minLevel="<i>integer</i>" /&gt;
&lt;/level-list&gt;
</pre>
</dd>

<dt>elements:</dt>

<dd>
<dl class="tag-list">

  <dt id="levellist-element"><code>&lt;level-list&gt;</code></dt>
  <dd>This must be the root element. Contains one or more <code>&lt;item&gt;</code> elements.
    <p class="caps">attributes:</p>
    <dl class="atn-list">
      <dt><code>xmlns:android</code></dt>
        <dd><em>String</em>. <strong>Required.</strong> Defines the XML namespace, which must be
        <code>"http://schemas.android.com/apk/res/android"</code>.
    </dl>
  </dd>

  <dt id="levellist-item-element"><code>&lt;item&gt;</code></dt>
  <dd>Defines a drawable to use at a certain level.
    <p class="caps">attributes:</p>
    <dl class="atn-list">
      <dt><code>android:drawable</code></dt>
        <dd><em>Drawable resource</em>. <strong>Required</strong>. Reference to a drawable
resource to be inset.</dd>
      <dt><code>android:maxLevel</code></dt>
        <dd><em>Integer</em>. The maximum level allowed for this item.</dd>
      <dt><code>android:minLevel</code></dt>
        <dd><em>Integer</em>. The minimum level allowed for this item.</dd>
    </dl>
  </dd>
</dl>

</dd>

<dt>example:</dt>

<dd>

<pre>
&lt;?xml version="1.0" encoding="utf-8"?>
&lt;level-list xmlns:android="http://schemas.android.com/apk/res/android" &gt;
    &lt;item
        android:drawable="@drawable/status_off"
        android:maxLevel="0" /&gt;
    &lt;item
        android:drawable="@drawable/status_on"
        android:maxLevel="1" /&gt;
&lt;/level-list&gt;
</pre>
<p>Once this is applied to a <code><a href="../../../reference/android/view/View.html">View</a></code>, the level can be changed with <code><a href="../../../reference/android/graphics/drawable/Drawable.html#setLevel(int)">setLevel()</a></code> or <code><a href="../../../reference/android/widget/ImageView.html#setImageLevel(int)">setImageLevel()</a></code>.</p>

</dd>

<dt>see also:</dt>

<dd>
<ul>
  <li><code><a href="../../../reference/android/graphics/drawable/LevelListDrawable.html">LevelListDrawable</a></code></li>
</ul>
</dd>

</dl>






<h2 id="Transition">Transition Drawable</h2>

<p>A <code><a href="../../../reference/android/graphics/drawable/TransitionDrawable.html">TransitionDrawable</a></code> is a drawable object
that can cross-fade between the two drawable resources.</p>

<p>Each drawable is represented by an <code>&lt;item&gt;</code> element inside a single <code>&lt;transition&gt;</code> element. No more than two items are supported. To transition forward, call
<code><a href="../../../reference/android/graphics/drawable/TransitionDrawable.html#startTransition(int)">startTransition()</a></code>. To
transition backward, call <code><a href="../../../reference/android/graphics/drawable/TransitionDrawable.html#reverseTransition(int)">reverseTransition()</a></code>.</p>

<dl class="xml">

<dt>file location:</dt>
<dd><code>res/drawable/<em>filename</em>.xml</code><br/>
The filename is used as the resource ID.</dd>

<dt>compiled resource datatype:</dt>
<dd>Resource pointer to a <code><a href="../../../reference/android/graphics/drawable/TransitionDrawable.html">TransitionDrawable</a></code>.</dd>

<dt>resource reference:</dt>

<dd>
In Java: <code>R.drawable.<em>filename</em></code><br/>
In XML: <code>@[<em>package</em>:]drawable/<em>filename</em></code>
</dd>

<dt>syntax:</dt>

<dd>
<pre class="stx">
&lt;?xml version="1.0" encoding="utf-8"?>
&lt;<a href="#transition-element">transition</a>
xmlns:android="http://schemas.android.com/apk/res/android" &gt;
    &lt;<a href="#transition-item-element">item</a>
        android:drawable="@[package:]drawable/<em>drawable_resource</em>"
        android:id="@[+][<em>package</em>:]id/<i>resource_name</i>"
        android:top="<em>dimension</em>"
        android:right="<em>dimension</em>"
        android:bottom="<em>dimension</em>"
        android:left="<em>dimension</em>" /&gt;
&lt;/transition>
</pre>
</dd>

<dt>elements:</dt>

<dd>
<dl class="tag-list">

  <dt id="transition-element"><code>&lt;transition&gt;</code></dt>
    <dd><strong>Required.</strong> This must be the root element. Contains one or more <code>&lt;item></code> elements.
      <p class="caps">attributes:</p>
      <dl class="atn-list">
        <dt><code>xmlns:android</code></dt>
          <dd><em>String</em>. <strong>Required.</strong> Defines the XML namespace, which must be
          <code>"http://schemas.android.com/apk/res/android"</code>.
      </dl>
    </dd>
  <dt id="transition-item-element"><code>&lt;item&gt;</code></dt>
    <dd>Defines a drawable to use as part of the drawable transition.
Must be a child of a <code>&lt;transition&gt;</code> element. Accepts child <code>&lt;bitmap&gt;</code>
elements.
      <p class="caps">attributes:</p>
      <dl class="atn-list">
        <dt><code>android:drawable</code></dt>
          <dd><em>Drawable resource</em>. <strong>Required</strong>. Reference to a drawable
resource.</dd>
        <dt><code>android:id</code></dt>
          <dd><em>Resource ID</em>. A unique resource ID for this drawable. To create a new resource
ID for this item, use the form:
<code>"@+id/<em>name</em>"</code>. The plus symbol indicates that this should be created as a new
ID. You can use this identifier to
retrieve and modify the drawable with <code><a href="../../../reference/android/view/View.html#findViewById(int)">View.findViewById()</a></code> or <code><a href="../../../reference/android/app/Activity.html#findViewById(int)">Activity.findViewById()</a></code>.</dd>
        <dt><code>android:top</code></dt>
          <dd><em>Integer</em>. The top offset in pixels.</dd>
        <dt><code>android:right</code></dt>
          <dd><em>Integer</em>. The right offset in pixels.</dd>
        <dt><code>android:bottom</code></dt>
          <dd><em>Integer</em>. The bottom offset in pixels.</dd>
        <dt><code>android:left</code></dt>
          <dd><em>Integer</em>. The left offset in pixels.</dd>
      </dl>
    </dd>

</dl>
</dd> <!-- end  elements and attributes -->

<dt>example:</dt>

<dd>XML file saved at <code>res/drawable/transition.xml</code>:
<pre>
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;transition xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;item android:drawable="@drawable/on" /&gt;
    &lt;item android:drawable="@drawable/off" /&gt;
&lt;/transition&gt;
</pre>

<p>This layout XML applies the drawable to a View:</p>
<pre>
&lt;ImageButton
    android:id="@+id/button"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:src="@drawable/transition" /&gt;
</pre>

<p>And the following code performs a 500ms transition from the first item to the second:</p>
<pre>
ImageButton button = (ImageButton) findViewById(R.id.button);
TransitionDrawable drawable = (TransitionDrawable) button.getDrawable();
drawable.startTransition(500);
</pre>

</dd> <!-- end example -->

<dt>see also:</dt>

<dd>
<ul>
  <li><code><a href="../../../reference/android/graphics/drawable/TransitionDrawable.html">TransitionDrawable</a></code></li>
</ul>
</dd>

</dl>





<h2 id="Inset">Inset Drawable</h2>

<p>A drawable defined in XML that insets another drawable by a specified distance. This is useful
when a View needs a background that is smaller than the View's actual bounds.</p>

<dl class="xml">

<dt>file location:</dt>
<dd><code>res/drawable/<em>filename</em>.xml</code><br/>
The filename is used as the resource ID.</dd>

<dt>compiled resource datatype:</dt>
<dd>Resource pointer to a <code><a href="../../../reference/android/graphics/drawable/InsetDrawable.html">InsetDrawable</a></code>.</dd>

<dt>resource reference:</dt>

<dd>
In Java: <code>R.drawable.<em>filename</em></code><br/>
In XML: <code>@[<em>package</em>:]drawable/<em>filename</em></code>
</dd>

<dt>syntax:</dt>

<dd>
<pre class="stx">
&lt;?xml version="1.0" encoding="utf-8"?>
&lt;<a href="#inset-element">inset</a>
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/<i>drawable_resource</i>"
    android:insetTop="<i>dimension</i>"
    android:insetRight="<i>dimension</i>"
    android:insetBottom="<i>dimension</i>"
    android:insetLeft="<i>dimension</i>" /&gt;
</pre>
</dd>

<dt>elements:</dt>

<dd>
<dl class="tag-list">

  <dt id="inset-element"><code>&lt;inset&gt;</code></dt>
  <dd>Defines the inset drawable. This must be the root element.
    <p class="caps">attributes:</p>
    <dl class="atn-list">
      <dt><code>xmlns:android</code></dt>
        <dd><em>String</em>. <strong>Required.</strong> Defines the XML namespace, which must be
        <code>"http://schemas.android.com/apk/res/android"</code>.
      <dt><code>android:drawable</code></dt>
        <dd><em>Drawable resource</em>. <strong>Required</strong>. Reference to a drawable
resource to be inset.</dd>
      <dt><code>android:insetTop</code></dt>
        <dd><em>Dimension</em>. The top inset, as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a></dd>
      <dt><code>android:insetRight</code></dt>
        <dd><em>Dimension</em>. The right inset, as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a></dd>
      <dt><code>android:insetBottom</code></dt>
        <dd><em>Dimension</em>. The bottom inset, as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a></dd>
      <dt><code>android:insetLeft</code></dt>
        <dd><em>Dimension</em>. The left inset, as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a></dd>
    </dl>
  </dd>
</dl>

</dd>

<dt>example:</dt>

<dd>
<pre>
&lt;?xml version="1.0" encoding="utf-8"?>
&lt;inset xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/background"
    android:insetTop="10dp"
    android:insetLeft="10dp" /&gt;
</pre>
</dd>

<dt>see also:</dt>

<dd>
<ul>
  <li><code><a href="../../../reference/android/graphics/drawable/InsetDrawable.html">InsetDrawable</a></code></li>
</ul>
</dd>

</dl>








<h2 id="Clip">Clip Drawable</h2>

<p>A drawable defined in XML that clips another drawable based on this Drawable's current level. You
can control how much the child drawable gets clipped in width and height based on the level, as well
as a gravity to control where it is placed in its overall container. Most often used to implement
things like progress bars.</p>

<dl class="xml">

<dt>file location:</dt>
<dd><code>res/drawable/<em>filename</em>.xml</code><br/>
The filename is used as the resource ID.</dd>

<dt>compiled resource datatype:</dt>
<dd>Resource pointer to a <code><a href="../../../reference/android/graphics/drawable/ClipDrawable.html">ClipDrawable</a></code>.</dd>

<dt>resource reference:</dt>

<dd>
In Java: <code>R.drawable.<em>filename</em></code><br/>
In XML: <code>@[<em>package</em>:]drawable/<em>filename</em></code>
</dd>

<dt>syntax:</dt>

<dd>
<pre class="stx">
&lt;?xml version="1.0" encoding="utf-8"?>
&lt;<a href="#clip-element">clip</a>
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/<i>drawable_resource</i>"
    android:clipOrientation=["horizontal" | "vertical"]
    android:gravity=["top" | "bottom" | "left" | "right" | "center_vertical" |
                     "fill_vertical" | "center_horizontal" | "fill_horizontal" |
                     "center" | "fill" | "clip_vertical" | "clip_horizontal"] /&gt;
</pre>
</dd>

<dt>elements:</dt>

<dd>
<dl class="tag-list">

  <dt id="clip-element"><code>&lt;clip&gt;</code></dt>
  <dd>Defines the clip drawable. This must be the root element.
    <p class="caps">attributes:</p>
    <dl class="atn-list">
      <dt><code>xmlns:android</code></dt>
        <dd><em>String</em>. <strong>Required.</strong> Defines the XML namespace, which must be
        <code>"http://schemas.android.com/apk/res/android"</code>.
      <dt><code>android:drawable</code></dt>
        <dd><em>Drawable resource</em>. <strong>Required</strong>. Reference to a drawable
resource to be clipped.</dd>
      <dt><code>android:clipOrientation</code></dt>
        <dd><em>Keyword</em>. The orientation for the clip.
          <p>Must be one of the following constant values:</p>
<table>
<tr><th>Value</th><th>Description</th></tr>
<tr><td><code>horizontal</code></td>
<td>Clip the drawable horizontally.</td></tr>
<tr><td><code>vertical</code></td>
<td>Clip the drawable vertically.</td></tr>
</table>
        </dd>
      <dt><code>android:gravity</code></dt>
        <dd><em>Keyword</em>. Specifies where to clip within the drawable.
          <p>Must be one or more (separated by '|') of the following constant values:</p>
<table>
<tr><th>Value</th><th>Description</th></tr>
<tr><td><code>top</code></td>
<td>Put the object at the top of its container, not changing its size. When <code>clipOrientation</code> is <code>"vertical"</code>, clipping occurs at the bottom of the drawable.</td></tr>
<tr><td><code>bottom</code></td>
<td>Put the object at the bottom of its container, not changing its size. When <code>clipOrientation</code> is <code>"vertical"</code>, clipping occurs at the top of the drawable.</td></tr>
<tr><td><code>left</code></td>
<td>Put the object at the left edge of its container, not changing its size. This is the
default. When <code>clipOrientation</code> is <code>"horizontal"</code>, clipping occurs at the right side of
the drawable. This is the default.</td></tr>
<tr><td><code>right</code></td>
<td>Put the object at the right edge of its container, not changing its size. When <code>clipOrientation</code> is <code>"horizontal"</code>, clipping occurs at the left side of
the drawable.</td></tr>
<tr><td><code>center_vertical</code></td>
<td>Place object in the vertical center of its container, not changing its size. Clipping behaves
the same as when gravity is <code>"center"</code>.</td></tr>
<tr><td><code>fill_vertical</code></td>
<td>Grow the vertical size of the object if needed so it completely fills its container. When <code>clipOrientation</code> is <code>"vertical"</code>, no clipping occurs because the drawable fills the
vertical space (unless the drawable level is 0, in which case it's not visible).</td></tr>
<tr><td><code>center_horizontal</code></td>
<td>Place object in the horizontal center of its container, not changing its size.
Clipping behaves the same as when gravity is <code>"center"</code>.</td></tr>
<tr><td><code>fill_horizontal</code></td>
<td>Grow the horizontal size of the object if needed so it completely fills its container. When
<code>clipOrientation</code> is <code>"horizontal"</code>, no clipping occurs because the drawable fills the
horizontal space (unless the drawable level is 0, in which case it's not visible).
</td></tr>
<tr><td><code>center</code></td>
<td>Place the object in the center of its container in both the vertical and horizontal axis, not
changing its size. When <code>clipOrientation</code> is <code>"horizontal"</code>, clipping occurs on the left and right. When <code>clipOrientation</code> is <code>"vertical"</code>, clipping occurs on the top and bottom.</td></tr>
<tr><td><code>fill</code></td>
<td>Grow the horizontal and vertical size of the object if needed so it completely fills its
container. No clipping occurs because the drawable fills the
horizontal and vertical space (unless the drawable level is 0, in which case it's not
visible).</td></tr>
<tr><td><code>clip_vertical</code></td>
<td>Additional option that can be set to have the top and/or bottom edges of the child clipped to
its container's bounds. The clip is based on the vertical gravity: a top gravity clips the
bottom edge, a bottom gravity clips the top edge, and neither clips both edges.
</td></tr>
<tr><td><code>clip_horizontal</code></td>
<td>Additional option that can be set to have the left and/or right edges of the child clipped to
its container's bounds. The clip is based on the horizontal gravity: a left gravity clips
the right edge, a right gravity clips the left edge, and neither clips both edges.
</td></tr>
</table></dd>
    </dl>
  </dd>
</dl>

</dd> <!-- end  elements and attributes -->

<dt>example:</dt>

<dd>XML file saved at <code>res/drawable/clip.xml</code>:
<pre>
&lt;?xml version="1.0" encoding="utf-8"?>
&lt;clip xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/android"
    android:clipOrientation="horizontal"
    android:gravity="left" /&gt;
&lt;/clip>
</pre>
    <p>The following layout XML applies the clip drawable to a View:</p>
<pre>
&lt;ImageView
    android:id="@+id/image"
    android:background="@drawable/clip"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content" />
</pre>

    <p>The following code gets the drawable and increases the amount of clipping in order to
progressively reveal the image:</p>
<pre>
ImageView imageview = (ImageView) findViewById(R.id.image);
ClipDrawable drawable = (ClipDrawable) imageview.getDrawable();
drawable.setLevel(drawable.getLevel() + 1000);
</pre>

<p>Increasing the level reduces the amount of clipping and slowly reveals the image. Here it is
at a level of 7000:</p>
<img src="../../../images/resources/clip.png" alt="" />

<p class="note"><strong>Note:</strong> The default level is 0, which is fully clipped so the image
is not visible. When the level is 10,000, the image is not clipped and completely visible.</p>
</dd> <!-- end example -->

<dt>see also:</dt>

<dd>
<ul>
  <li><code><a href="../../../reference/android/graphics/drawable/ClipDrawable.html">ClipDrawable</a></code></li>
</ul>
</dd>

</dl>









<h2 id="Scale">Scale Drawable</h2>

<p>A drawable defined in XML that changes the size of another drawable based on its current
level.</p>

<dl class="xml">

<dt>file location:</dt>
<dd><code>res/drawable/<em>filename</em>.xml</code><br/>
The filename is used as the resource ID.</dd>

<dt>compiled resource datatype:</dt>
<dd>Resource pointer to a <code><a href="../../../reference/android/graphics/drawable/ScaleDrawable.html">ScaleDrawable</a></code>.</dd>

<dt>resource reference:</dt>

<dd>
In Java: <code>R.drawable.<em>filename</em></code><br/>
In XML: <code>@[<em>package</em>:]drawable/<em>filename</em></code>
</dd>

<dt>syntax:</dt>

<dd>
<pre class="stx">
&lt;?xml version="1.0" encoding="utf-8"?>
&lt;<a href="#scale-element">scale</a>
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/<i>drawable_resource</i>"
    android:scaleGravity=["top" | "bottom" | "left" | "right" | "center_vertical" |
                          "fill_vertical" | "center_horizontal" | "fill_horizontal" |
                          "center" | "fill" | "clip_vertical" | "clip_horizontal"]
    android:scaleHeight="<i>percentage</i>"
    android:scaleWidth="<i>percentage</i>" /&gt;
</pre>
</dd>

<dt>elements:</dt>

<dd>
<dl class="tag-list">

  <dt id="scale-element"><code>&lt;scale&gt;</code></dt>
  <dd>Defines the scale drawable. This must be the root element.
    <p class="caps">attributes:</p>
    <dl class="atn-list">
      <dt><code>xmlns:android</code></dt>
        <dd><em>String</em>. <strong>Required.</strong> Defines the XML namespace, which must be
        <code>"http://schemas.android.com/apk/res/android"</code>.
      <dt><code>android:drawable</code></dt>
        <dd><em>Drawable resource</em>. <strong>Required</strong>. Reference to a drawable
resource.</dd>
      <dt><code>android:scaleGravity</code></dt>
        <dd><em>Keyword</em>. Specifies the gravity position after scaling.
          <p>Must be one or more (separated by '|') of the following constant values:</p>
<table>
<tr><th>Value</th><th>Description</th></tr>
<tr><td><code>top</code></td>
<td>Put the object at the top of its container, not changing its size.</td></tr>
<tr><td><code>bottom</code></td>
<td>Put the object at the bottom of its container, not changing its size. </td></tr>
<tr><td><code>left</code></td>
<td>Put the object at the left edge of its container, not changing its size. This is the
default.</td></tr>
<tr><td><code>right</code></td>
<td>Put the object at the right edge of its container, not changing its size. </td></tr>
<tr><td><code>center_vertical</code></td>
<td>Place object in the vertical center of its container, not changing its size. </td></tr>
<tr><td><code>fill_vertical</code></td>
<td>Grow the vertical size of the object if needed so it completely fills its container. </td></tr>
<tr><td><code>center_horizontal</code></td>
<td>Place object in the horizontal center of its container, not changing its size. </td></tr>
<tr><td><code>fill_horizontal</code></td>
<td>Grow the horizontal size of the object if needed so it completely fills its container.
</td></tr>
<tr><td><code>center</code></td>
<td>Place the object in the center of its container in both the vertical and horizontal axis, not
changing its size. </td></tr>
<tr><td><code>fill</code></td>
<td>Grow the horizontal and vertical size of the object if needed so it completely fills its
container. </td></tr>
<tr><td><code>clip_vertical</code></td>
<td>Additional option that can be set to have the top and/or bottom edges of the child clipped to
its container's bounds. The clip is based on the vertical gravity: a top gravity clips the
bottom edge, a bottom gravity clips the top edge, and neither clips both edges.
</td></tr>
<tr><td><code>clip_horizontal</code></td>
<td>Additional option that can be set to have the left and/or right edges of the child clipped to
its container's bounds. The clip is based on the horizontal gravity: a left gravity clips
the right edge, a right gravity clips the left edge, and neither clips both edges.
</td></tr>
</table></dd>
      <dt><code>android:scaleHeight</code></dt>
        <dd><em>Percentage</em>. The scale height, expressed as a percentage of the drawable's
bound. The value's format is XX%. For instance: 100%, 12.5%, etc.</dd>
      <dt><code>android:scaleWidth</code></dt>
        <dd><em>Percentage</em>. The scale width, expressed as a percentage of the drawable's
bound. The value's format is XX%. For instance: 100%, 12.5%, etc.</dd>
    </dl>
  </dd>
</dl>

</dd>

<dt>example:</dt>

<dd>
<pre class="stx">
&lt;?xml version="1.0" encoding="utf-8"?>
&lt;scale xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/logo"
    android:scaleGravity="center_vertical|center_horizontal"
    android:scaleHeight="80%"
    android:scaleWidth="80%" /&gt;
</pre>
</dd>

<dt>see also:</dt>
<dd>
<ul>
  <li><code><a href="../../../reference/android/graphics/drawable/ScaleDrawable.html">ScaleDrawable</a></code></li>
</ul>
</dd>

</dl>







<h2 id="Shape">Shape Drawable</h2>

<p>This is a generic shape defined in XML.</p>

<dl class="xml">

<dt>file location:</dt>
<dd><code>res/drawable/<em>filename</em>.xml</code><br/>
The filename is used as the resource ID.</dd>

<dt>compiled resource datatype:</dt>
<dd>Resource pointer to a <code><a href="../../../reference/android/graphics/drawable/GradientDrawable.html">GradientDrawable</a></code>.</dd>

<dt>resource reference:</dt>

<dd>
In Java: <code>R.drawable.<em>filename</em></code><br/>
In XML: <code>@[<em>package</em>:]drawable/<em>filename</em></code>
</dd>

<dt>syntax:</dt>

<dd>
<pre class="stx">
&lt;?xml version="1.0" encoding="utf-8"?>
&lt;<a href="#shape-element">shape</a>
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape=["rectangle" | "oval" | "line" | "ring"] >
    &lt;<a href="#corners-element">corners</a>
        android:radius="<em>integer</em>"
        android:topLeftRadius="<em>integer</em>"
        android:topRightRadius="<em>integer</em>"
        android:bottomLeftRadius="<em>integer</em>"
        android:bottomRightRadius="<em>integer</em>" /&gt;
    &lt;<a href="#gradient-element">gradient</a>
        android:angle="<em>integer</em>"
        android:centerX="<em>integer</em>"
        android:centerY="<em>integer</em>"
        android:centerColor="<em>integer</em>"
        android:endColor="<em>color</em>"
        android:gradientRadius="<em>integer</em>"
        android:startColor="<em>color</em>"
        android:type=["linear" | "radial" | "sweep"]
        android:usesLevel=["true" | "false"] /&gt;
    &lt;<a href="#padding-element">padding</a>
        android:left="<em>integer</em>"
        android:top="<em>integer</em>"
        android:right="<em>integer</em>"
        android:bottom="<em>integer</em>" /&gt;
    &lt;<a href="#size-element">size</a>
        android:width="<em>integer</em>"
        android:height="<em>integer</em>" /&gt;
    &lt;<a href="#solid-element">solid</a>
        android:color="<em>color</em>" /&gt;
    &lt;<a href="#stroke-element">stroke</a>
        android:width="<em>integer</em>"
        android:color="<em>color</em>"
        android:dashWidth="<em>integer</em>"
        android:dashGap="<em>integer</em>" /&gt;
&lt;/shape>
</pre>
</dd>

<dt>elements:</dt>

<dd>
<dl class="tag-list">

  <dt id="shape-element"><code>&lt;shape&gt;</code></dt>
    <dd>The shape drawable. This must be the root element.
      <p class="caps">attributes:</p>
      <dl class="atn-list">
        <dt><code>xmlns:android</code></dt>
          <dd><em>String</em>. <strong>Required.</strong> Defines the XML namespace, which must be
          <code>"http://schemas.android.com/apk/res/android"</code>.
        <dt><code>android:shape</code></dt>
        <dd><em>Keyword</em>. Defines the type of shape. Valid values are:
          <table>
            <tr><th>Value</th><th>Desciption</th></tr>
            <tr><td><code>"rectangle"</code></td>
                <td>A rectangle that fills the containing View. This is the default shape.</td></tr>
            <tr><td><code>"oval"</code></td>
                <td>An oval shape that fits the dimensions of the containing View.</td></tr>
            <tr><td><code>"line"</code></td>
                <td>A horizontal line that spans the width of the containing View. This
                shape requires the <code>&lt;stroke></code> element to define the width of the
                line.</td></tr>
            <tr><td><code>"ring"</code></td>
                <td>A ring shape.</td></tr>
          </table>
        </dd>
      </dl>
      <p>The following attributes are used only when <code>android:shape="ring"</code>:</p>
      <dl class="atn-list">
        <dt><code>android:innerRadius</code></dt>
        <dd><em>Dimension</em>. The radius for the
inner part of the ring (the hole in the middle), as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a>.</dd>
        <dt><code>android:innerRadiusRatio</code></dt>
        <dd><em>Float</em>. The radius for the inner
part of the ring, expressed as a ratio of the ring's width. For instance, if <code>android:innerRadiusRatio="5"</code>, then the inner radius equals the ring's width divided by 5. This
value is overridden by <code>android:innerRadius</code>. Default value is 9.</dd>
        <dt><code>android:thickness</code></dt>
        <dd><em>Dimension</em>. The thickness of the
ring, as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a>.</dd>
        <dt><code>android:thicknessRatio</code></dt>
        <dd><em>Float</em>. The thickness of the ring,
expressed as a ratio of the ring's width. For instance, if <code>android:thicknessRatio="2"</code>, then
the thickness equals the ring's width divided by 2. This value is overridden by <code>android:innerRadius</code>. Default value is 3.</dd>
        <dt><code>android:useLevel</code></dt>
        <dd><em>Boolean</em>. "true" if this is used as
a <code><a href="../../../reference/android/graphics/drawable/LevelListDrawable.html">LevelListDrawable</a></code>. This should normally be "false"
          or your shape may not appear.</dd>
      </dl>
  <dt id="corners-element"><code>&lt;corners&gt;</code></dt>
    <dd>Creates rounded corners for the shape. Applies only when the shape is a rectangle.
      <p class="caps">attributes:</p>
      <dl class="atn-list">
        <dt><code>android:radius</code></dt>
        <dd><em>Dimension</em>. The radius for all corners, as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a>. This is overridden for each
corner by the following attributes.</dd>
        <dt><code>android:topLeftRadius</code></dt>
        <dd><em>Dimension</em>. The radius for the top-left corner, as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a>.</dd>
        <dt><code>android:topRightRadius</code></dt>
        <dd><em>Dimension</em>. The radius for the top-right corner, as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a>.</dd>
        <dt><code>android:bottomLeftRadius</code></dt>
        <dd><em>Dimension</em>. The radius for the bottom-left corner, as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a>.</dd>
        <dt><code>android:bottomRightRadius</code></dt>
        <dd><em>Dimension</em>. The radius for the bottom-right corner, as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a>.</dd>
      </dl>
      <p class="note"><strong>Note:</strong> Every corner must (initially) be provided a corner
radius greater than 1, or else no corners are rounded. If you want specific corners
to <em>not</em> be rounded, a work-around is to use <code>android:radius</code> to set a default corner
radius greater than 1, but then override each and every corner with the values you really
want, providing zero ("0dp") where you don't want rounded corners.</p>
    </dd>
  <dt id="gradient-element"><code>&lt;gradient&gt;</code></dt>
    <dd>Specifies a gradient color for the shape.
      <p class="caps">attributes:</p>
      <dl class="atn-list">
        <dt><code>android:angle</code></dt>
        <dd><em>Integer</em>. The angle for the gradient, in degrees. 0 is left to right, 90 is
bottom to top. It must be a multiple of 45. Default is 0.</dd>
        <dt><code>android:centerX</code></dt>
        <dd><em>Float</em>. The relative X-position for the center of the gradient (0 - 1.0).</dd>
        <dt><code>android:centerY</code></dt>
        <dd><em>Float</em>. The relative Y-position for the center of the gradient (0 - 1.0).</dd>
        <dt><code>android:centerColor</code></dt>
        <dd><em>Color</em>. Optional color that comes between the start and end colors, as a
hexadecimal value or <a href="more-resources.html#Color">color resource</a>.</dd>
        <dt><code>android:endColor</code></dt>
        <dd><em>Color</em>. The ending color, as a hexadecimal
value or <a href="more-resources.html#Color">color resource</a>.</dd>
        <dt><code>android:gradientRadius</code></dt>
        <dd><em>Float</em>. The radius for the gradient. Only applied when <code>android:type="radial"</code>.</dd>
        <dt><code>android:startColor</code></dt>
        <dd><em>Color</em>. The starting color, as a hexadecimal
value or <a href="more-resources.html#Color">color resource</a>.</dd>
        <dt><code>android:type</code></dt>
        <dd><em>Keyword</em>. The type of gradient pattern to apply. Valid values are:
          <table>
            <tr><th>Value</th><th>Description</th></tr>
            <tr><td><code>"linear"</code></td>
                <td>A linear gradient. This is the default.</td></tr>
            <tr><td><code>"radial"</code></td>
                <td>A radial gradient. The start color is the center color.</td></tr>
            <tr><td><code>"sweep"</code></td>
                <td>A sweeping line gradient. </td></tr>
          </table>
        </dd>
        <dt><code>android:useLevel</code></dt>
        <dd><em>Boolean</em>. "true" if this is used as a <code><a href="../../../reference/android/graphics/drawable/LevelListDrawable.html">LevelListDrawable</a></code>.</dd>
      </dl>
    </dd>
  <dt id="padding-element"><code>&lt;padding&gt;</code></dt>
    <dd>Padding to apply to the containing View element (this pads the position of the View
content, not the shape).
      <p class="caps">attributes:</p>
      <dl class="atn-list">
        <dt><code>android:left</code></dt>
        <dd><em>Dimension</em>. Left padding, as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a>.</dd>
        <dt><code>android:top</code></dt>
        <dd><em>Dimension</em>. Top padding, as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a>.</dd>
        <dt><code>android:right</code></dt>
        <dd><em>Dimension</em>. Right padding, as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a>.</dd>
        <dt><code>android:bottom</code></dt>
        <dd><em>Dimension</em>. Bottom padding, as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a>.</dd>
      </dl>
    </dd>
  <dt id="size-element"><code>&lt;size&gt;</code></dt>
    <dd>The size of the shape.
      <p class="caps">attributes:</p>
      <dl class="atn-list">
        <dt><code>android:height</code></dt>
        <dd><em>Dimension</em>. The height of the shape, as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a>.</dd>
        <dt><code>android:width</code></dt>
        <dd><em>Dimension</em>. The width of the shape, as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a>.</dd>
      </dl>
      <p class="note"><strong>Note:</strong> The shape scales to the size of the container
View proportionate to the dimensions defined here, by default. When you use the shape in an <code><a href="../../../reference/android/widget/ImageView.html">ImageView</a></code>, you can restrict scaling by setting the <a
href="../../../reference/android/widget/ImageView.html#attr_android:scaleType"><code>android:scaleType</code></a> to <code>"center"</code>.</p>
    </dd>
  <dt id="solid-element"><code>&lt;solid&gt;</code></dt>
    <dd>A solid color to fill the shape.
      <p class="caps">attributes:</p>
      <dl class="atn-list">
        <dt><code>android:color</code></dt>
        <dd><em>Color</em>. The color to apply to the shape, as a hexadecimal
value or <a href="more-resources.html#Color">color resource</a>.</dd>
      </dl>
    </dd>
  <dt id="stroke-element"><code>&lt;stroke&gt;</code></dt>
    <dd>A stroke line for the shape.
      <p class="caps">attributes:</p>
      <dl class="atn-list">
        <dt><code>android:width</code></dt>
        <dd><em>Dimension</em>. The thickness of the line, as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a>.</dd>
        <dt><code>android:color</code></dt>
        <dd><em>Color</em>. The color of the line, as a
hexadecimal value or <a href="more-resources.html#Color">color resource</a>.</dd>
        <dt><code>android:dashGap</code></dt>
        <dd><em>Dimension</em>. The distance between line dashes, as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a>. Only valid if <code>android:dashWidth</code> is set.</dd>
        <dt><code>android:dashWidth</code></dt>
        <dd><em>Dimension</em>. The size of each dash line, as a dimension value or <a
href="more-resources.html#Dimension">dimension resource</a>. Only valid if <code>android:dashGap</code> is set.</dd>
      </dl>
    </dd>

</dl>
</dd> <!-- end  elements and attributes -->

<dt>example:</dt>

<dd>XML file saved at <code>res/drawable/gradient_box.xml</code>:
<pre>
&lt;?xml version="1.0" encoding="utf-8"?>
&lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    &lt;gradient
        android:startColor="#FFFF0000"
        android:endColor="#80FF00FF"
        android:angle="45"/>
    &lt;padding android:left="7dp"
        android:top="7dp"
        android:right="7dp"
        android:bottom="7dp" />
    &lt;corners android:radius="8dp" />
&lt;/shape>
</pre>

    <p>This layout XML applies the shape drawable to a View:</p>
<pre>
&lt;TextView
    android:background="@drawable/gradient_box"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content" />
</pre>

    <p>This application code gets the shape drawable and applies it to a View:</p>
<pre>
Resources res = <code><a href="../../../reference/android/content/Context.html#getResources()">getResources()</a></code>;
Drawable shape = res. <code><a href="../../../reference/android/content/res/Resources.html#getDrawable(int)">getDrawable</a></code>(R.drawable.gradient_box);

TextView tv = (TextView)findViewByID(R.id.textview);
tv.setBackground(shape);
</pre>
</dd> <!-- end example -->

<dt>see also:</dt>

<dd>
<ul>
  <li><code><a href="../../../reference/android/graphics/drawable/ShapeDrawable.html">ShapeDrawable</a></code></li>
</ul>
</dd>

</dl>














    </div>

  <a href="#top" style="float:right">&uarr; Go to top</a>
  
    <p><a href="available-resources.html">&larr; Back to Resource Types</a></p>
  
  </div>

<div id="footer">


  <div id="copyright">
    
  Except as noted, this content is licensed under <a
  href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2.0</a>. 
  For details and restrictions, see the <a href="../../../license.html">
  Content License</a>.
  </div>
  <div id="build_info">
    
  Android 4.0&nbsp;r1 - 17 Oct 2011 18:17

  </div>

  <div id="footerlinks">
    
  <p>
    <a href="http://www.android.com/terms.html">Site Terms of Service</a> -
    <a href="http://www.android.com/privacy.html">Privacy Policy</a> -
    <a href="http://www.android.com/branding.html">Brand Guidelines</a>
  </p>
  </div>

</div> <!-- end footer -->

</div><!-- end doc-content -->

</div> <!-- end body-content --> 

<script type="text/javascript">
init(); /* initialize android-developer-docs.js */
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-5831155-1");
pageTracker._trackPageview();
</script>

</body>
</html>



